#pragma once
#include <vector>
#include "sre/Camera.hpp"
#include "sre/SpriteBatch.hpp"
#include "sre/SpriteAtlas.hpp"
#include "sre/Texture.hpp"
#include "Box2D/Dynamics/b2World.h"
#include "Event.hpp"
#include "GameObject.hpp"
#include "LevelManager.h"
#include "Box2DDebugDraw.hpp"

class Scene : public b2ContactListener {
public:
	Scene();
	~Scene();

	void update(float);
	void Draw();
	void PhysicsUpdate();
	void End();
	void LoadLevel(std::string);

	Event<void(float)> Update;
	Event<void(sre::SpriteBatch::SpriteBatchBuilder&)> DrawScene;
	Event<void()> PhysicsStep;
	Event<void(SDL_Event&)> KeyEvent;

	LevelManager levelManager;

	std::shared_ptr<GameObject> Find(std::string);

	float GetPhysicsScale();
	void LevelOver();
private:
	float pos = 1.0f;
	int id;
	std::shared_ptr<b2World> physicsWorld;
	
	Box2DDebugDraw debugDraw;
	const float physicsScale = 30;
	std::shared_ptr<GameObject> findRecursive(std::shared_ptr<GameObject>, std::string);
	bool CheckForWinState();
	bool isLevelRunning = true;
	void BeginContact(b2Contact*);
	void EndContact(b2Contact*);
	void Contact(b2Contact*, CollisionPhase);

	bool doDebug = true;
};

