#pragma once
#include "Mod.h"

class Scaffold : public Mod {
public:
	int placement = 0;
	int rotations = 0;
	int swing = 0;
	int spoof = 0;
	int blocksleft = 1;
	bool bold = true;
	float extend = 1.8f;
	bool tower = true;
	bool moveabletower = false;
	float towerspeed = 0.4f;
	float moveabletowerspeed = 0.4f;
	bool ylock = true;
	bool autoblock = true;
	float ydown = 0.f;
	float minplacedelay, maxplacedelay = 0.f;
	float mintowerplacedelay, maxtowerplacedelay = 0.f;
	bool subplace = false;
	float minsubplacedelay, maxsubplacedelay = 0.f;
	Scaffold() : Mod(_("Scaffold"), _("Place the block under you."), Category::PLAYER) {

		settings.push_back(new Setting{ _("Placement"), &placement, new int(1), new int(0), 1, {
			_("Normal"), 
			_("Flareon")
			}, true });

		settings.push_back(new Setting{ _("Y Down"), &ydown, new float(1.f), new float(0.f), 2, {}, true });

		settings.push_back(new Setting{ _("Min Place Delay"), &minplacedelay, new float(200.f), new float(0.f), 2, {}, true, 0.5f });
		settings.push_back(new Setting{ _("Max Place Delay"), &maxplacedelay, new float(200.f), new float(0.f), 2, {}, true, 0.5f });

		settings.push_back(new Setting{ _("Min Tower Place Delay"), &mintowerplacedelay, new float(200.f), new float(0.f), 2, {}, true, 0.5f });
		settings.push_back(new Setting{ _("Max Tower Place Delay"), &maxtowerplacedelay, new float(200.f), new float(0.f), 2, {}, true, 0.5f });

		settings.push_back(new Setting{ _("Sub Place"), &subplace, 0, 0, 0, {}, true });
		settings.push_back(new Setting{ _("Min Sub Place Delay"), &minsubplacedelay, new float(200.f), new float(0.f), 2, {}, true, 0.5f });
		settings.push_back(new Setting{ _("Max Sub Place Delay"), &maxsubplacedelay, new float(200.f), new float(0.f), 2, {}, true, 0.5f });

		settings.push_back(new Setting{ _("Rotations"), &rotations, new int(3), new int(0), 1, {
			_("Normal"), 
			_("Back"),
			_("Down"),
			_("Silent")
			}, true});
		settings.push_back(new Setting{ _("Swing"), &swing, new int(2), new int(0), 1, {
			_("Normal"), 
			_("Fake"),
			_("Off")
			}, true });
		settings.push_back(new Setting{ _("Spoof"), &spoof, new int(1), new int(0), 1, {
			_("Off"), 
			_("Fake")
			}, true });
	
		
		settings.push_back(new Setting{ _("Blocks Left"), &blocksleft, new int(2), new int(0), 1, {
			_("None"), 
			_("Fancy"),
			_("Classic")
			}, true });
		settings.push_back(new Setting{ _("Bold"), &bold, 0, 0, 0, {}, true });

		settings.push_back(new Setting{ _("Extend"), &extend, new float(3.f), new float(0.f), 2, {}, true });

		settings.push_back(new Setting{ _("Tower"), &tower, 0, 0, 0, {}, true });
		settings.push_back(new Setting{ _("Moveable Tower"), &moveabletower, 0, 0, 0, {}, true });

		settings.push_back(new Setting{ _("Tower Speed"), &towerspeed, new float(1.f), new float(0.f), 2, {}, true });
		settings.push_back(new Setting{ _("Moveable Tower Speed"), &moveabletowerspeed, new float(1.f), new float(0.f), 2, {}, true });
	
		settings.push_back(new Setting{ _("Y Lock"), &ylock, 0, 0, 0, {}, true });
		settings.push_back(new Setting{ _("Auto Block"), &autoblock, 0, 0, 0, {}, true });
		
		enabled = false;
		onlyenabled = false;
	}

	bool placing = false;
	bool hasTowered = false;
private:
	glm::vec3 blockpos = glm::vec3();
	int oldslot = -1;
	float targetY;
	bool cancelswing = false;

	auto canPlace(glm::vec3 pos) -> bool;
	auto buildBlock(glm::vec3 pos, GameMode* gamemode, Player* player, PlayerInventory* playerinventory, Inventory* inventory) -> bool;
	auto predictBlock(glm::vec3 pos, GameMode* gamemode, Player* player, PlayerInventory* playerinventory, Inventory* inventory) -> bool;

	auto handlePacket(Packet* packet, Player* arg1) -> void;

	virtual auto onSwing(Player* player, bool* cancel) -> void override;
	virtual auto onWorldTick(Player* player) -> void override;
	virtual auto onPacketSendBefore(Packet* packet) -> void override;
	virtual auto onPacketSendAfter2(Packet* packet, bool* cancel) -> void override;
	virtual auto onImGuiRender() -> void override;
	virtual auto onClient() -> void override;
	virtual auto onEnabled() -> void override;
	virtual auto onDisabled() -> void override;
	virtual auto getMode() -> std::string override;
};
