/********************************************************************
*
* Created: 25/2/2014 13:46
*
* File: fsCSpriteComponent.h
*
* Author: Mick Waites
*
* Purpose: A component which renders a sprite to the display.
*
*********************************************************************/
#ifndef fsCSpriteComponenthdr
#define fsCSpriteComponenthdr
// Needed for COLLISION_DEBUG_MESSAGES definition
#include <fsAppCore/src/components/fsCDragDropComponent.h>
#include <fsCore/src/fsCUniqueId.h>
#include <fsCore/fsBaseTypes.h>
#include "../../fsIRenderData.h"
#include "fsISpriteComponent.h"
// #define OUTLINE_RENDERING
#ifdef COLLISION_DEBUG_MESSAGES
#define COLLISION_OUTLINE_RENDERING
#endif
class fsCSprite;
class fsCLine;
struct fsPoint;
class fsSColour;
class fsCEntity;
class fsIComponent;
class fsCVariableTable;
class fsCBrush;
class fsRect;
class fsCSpriteComponent : public fsISpriteComponent
{
friend class fsCComponentFactory;
friend class fsCVertexStreamSpriteRenderData;
public:
static const fsCUniqueId mTypeId;
void polyInfoSet(fsIRenderData::fsSPolyInfo const& pPolyInfo);
protected:
fsBool obscuredByBoundingBoxCheckDo(fsISpriteComponent* pOtherSprComp) override;
void alphaBlendSetDo(fsS32 pBlend) override;
fsBool hitTestDo(fsISpriteComponent* pOtherSprComp, fsBool pRequireHitMap) const override;
fsBool hitTestDo(const fsPoint& pScreenPos, fsBool pRequireHitMap) const override;
fsS32 widthGetDo() const override;
fsS32 heightGetDo() const override;
void colourSetDo(const fsSColour4B& pColour) override;
void widthSetDo(fsS32 pWidth, fsBool pModifyRenderData = true) override;
void heightSetDo(fsS32 pHeight, fsBool pModifyRenderData = true) override;
std::shared_ptr<fsCBrush> brushGetDo() const override;
void brushSetDo(std::shared_ptr<fsCBrush> pBrush) override;
static fsIComponent* create(fsCEntity* pParent);
void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;
void renderDo() override;
void matrixApplyDo() override;
fsCSpriteComponent(fsCEntity* pParent);
virtual ~fsCSpriteComponent();<--- Destructor in derived class
private:
#ifdef COLLISION_OUTLINE_RENDERING
void renderDebugCollisionOutline(const fsRect& intersect, const fsSColour4B& pColour) const;
void renderDebugMouseOverCollisionBox() const;
void clearDebugCollisionOutline() const;
#endif
#ifdef OUTLINE_RENDERING
void debugOutlineUpdate() const;
#endif
fsCSprite* mSprite;
#ifdef OUTLINE_RENDERING
fsCLine* mLine;
#endif
#ifdef COLLISION_OUTLINE_RENDERING
fsCLine* mCollisionOutlineLine;
#endif
};
#endif