#ifndef WATER_MODULE_H
#define WATER_MODULE_H
#include <vector>
#include <flecs.h>
namespace ECS
{
struct WaterSurface {
	Ogre::SceneNode *mWaterNode;
	Ogre::Entity *mWaterEnt;
	Ogre::RenderTexture *mReflectionTexture;
	Ogre::Camera *mReflectionCamera, *mRefractionCamera;
	Ogre::SceneNode *mReflectionCameraNode, *mRefractionCameraNode;
	Ogre::Camera *mReflectionDepthCamera;
	Ogre::Camera *mRefractionDepthCamera;
	Ogre::RenderTargetListener *mTargetListener;
	Ogre::MaterialPtr mDepthMaterial;
	Ogre::Technique *mDepthTech;
	bool mInRefTexUpdate;
	bool mAbove;
	struct RenderTextureListener
		: public Ogre::RenderTargetListener,
		  public Ogre::RenderQueue::RenderableListener {
		WaterSurface *mSurface;
		bool mInDepth;
		void preRenderTargetUpdate(
			const Ogre::RenderTargetEvent &evt) override;
		void postRenderTargetUpdate(
			const Ogre::RenderTargetEvent &evt) override;
		bool renderableQueued(Ogre::Renderable *rend,
				      Ogre::uint8 groupID, ushort priority,
				      Ogre::Technique **ppTech,
				      Ogre::RenderQueue *pQueue);
	};
	RenderTextureListener mRenderTargetListener;
	Ogre::Plane mWaterPlane, mReflectionPlane, mReflectionClipPlaneAbove,
		mReflectionClipPlaneBelow, mRefractionClipPlaneAbove,
		mRefractionClipPlaneBelow;
	Ogre::Viewport *mViewports[4];
};
struct InWater {};
struct WaterAlmostReady {};
struct WaterReady {};
struct WaterModule {
	// btPairCachingGhostObject *mGhostObject;
	WaterModule(flecs::world &ecs);
	// void createWaterShape(WaterBody *water);
};
}
#endif