12Entity::Entity(uint32_t uid): m_X(0.0f),m_Y(0.0f),m_PreviousX(0.0f),m_PreviousY(0.0f),m_UID(uid){}
59 m_Width(width),m_Height(height),m_Layer(layer),m_UID(uid){
65 m_Texture(t),m_Width(width),m_Height(height),m_Layer(layer),m_UID(uid){}
68 unsigned int tile_height,
int mag_filter,
int min_filter,
float width,
float height,
int layer,
bool play_animation,
69 bool loop_animation,
float animation_delay,
int animation_index,uint32_t uid):
71 m_Width(width),m_Height(height),m_Layer(layer),m_PlayAnimation(play_animation),
72 m_LoopAnimation(loop_animation),m_AnimationDelay(animation_delay),m_AnimationIndex(animation_index),m_LastAnimationTime(0),m_UID(uid){
78 m_AnimatedTexture(t),m_Width(width),m_Height(height),m_Layer(layer),m_PlayAnimation(play_animation),
79 m_LoopAnimation(loop_animation),m_AnimationDelay(animation_delay),m_AnimationIndex(animation_index),m_LastAnimationTime(0),m_UID(uid){}
132 m_XOffset(x_offset),m_YOffset(y_offset),m_Radius(radius),m_Blur(blur),m_Color(color),m_Type(type),m_UID(uid){}
215 printf(
"Texture components don't need to be updated!\n");
220 printf(
"Animated texture components don't need to be updated!\n");
225 printf(
"Light components don't need to be updated!\n");
232 for(
int i=0;
i<m_Components.size();
i++){
233 if(m_Components[
i].OnUpdate){
234 m_Components[
i].OnUpdate(scene,&m_Components[
i],frame_time);
244 for(
int i=0;
i<m_Components.size();
i++){
245 entity=scene->
GetEntity(m_Components[
i].m_UID);
246 if(m_Components[
i].m_Texture.get()->GetTexID()!=std::numeric_limits<uint32_t>::max()){
257 for(
int i=0;
i<m_Components.size();
i++){
258 entity=scene->
GetEntity(m_Components[
i].m_UID);
259 if(m_Components[
i].m_AnimatedTexture.get()->GetTexID()!=std::numeric_limits<uint32_t>::max()){
261 m_Components[
i].m_PlayAnimation,m_Components[
i].m_LoopAnimation,m_Components[
i].m_AnimationDelay,m_Components[
i].m_LastAnimationTime,m_Components[
i].m_AnimationIndex);
271 for(
int i=0;
i<m_Components.size();
i++){
272 entity=scene->
GetEntity(m_Components[
i].m_UID);
273 RENDERER->
DrawLight({
Interpolate(entity->
m_X,entity->
m_PreviousX)+m_Components[
i].m_XOffset,
Interpolate(entity->
m_Y,entity->
m_PreviousY)+m_Components[
i].m_YOffset},
Vec4(m_Components[
i].m_Color.r,m_Components[
i].m_Color.g,m_Components[
i].m_Color.b,1.0f),m_Components[
i].m_Type,m_Components[
i].m_Radius,m_Components[
i].m_Blur);
282 for(
int i=0;
i<m_Components.size();
i++){
283 entity=scene->
GetEntity(m_Components[
i].m_UID);
284 if(m_Components[
i].m_TextRenderer!=
nullptr)
285 m_Components[
i].m_TextRenderer->DrawText(m_Components[
i].m_Text,
Interpolate(entity->
m_X,entity->
m_PreviousX)+m_Components[
i].m_Offset.x,
Interpolate(entity->
m_Y,entity->
m_PreviousY)+m_Components[
i].m_Offset.y,m_Components[
i].m_Scale,(m_Components[
i].m_IgnoreLighting?std::numeric_limits<int>::max()-1:m_Components[
i].m_Layer),m_Components[
i].m_Color);
AnimatedTextureComponent()
void PlayAnimation(bool loop=false, float delay=0.0f)
float m_LastAnimationTime
std::shared_ptr< SpriteSheet > m_AnimatedTexture
void Render(Scene *scene)
void Update(Scene *scene, float frame_time)
Entity & operator=(const Entity &other)
void SetOffset(float x_offset, float y_offset)
void SetCentered(float width, float height)
void DrawTexture(Vec2 pos, Vec2 size, int layer, float texID)
void DrawLight(Vec2 pos, Vec4 color, LightType light_type, float radius=0.0f, float blurAmount=0.0f)
void DrawAnimatedTexture(Vec2 pos, Vec2 size, int layer, SpriteSheet &s, bool &play_animation, bool loop_animation, float animation_delay, float &last_animation_time, int &animation_index)
Entity * GetEntity(uint32_t uid)
TextComponent & operator=(const TextComponent &other)
std::shared_ptr< TextRenderer > m_TextRenderer
void SetCentered(float width, float height)
std::shared_ptr< Texture > m_Texture
std::pair< uint32_t, std::shared_ptr< SpriteSheet > > GetSpriteSheet(const std::string &path, unsigned int tile_width, unsigned int tile_height, int mag_filter, int min_filter)
std::pair< uint32_t, std::shared_ptr< Texture > > GetTexture(const std::string &path, int mag_filter, int min_filter)
std::ostream & operator<<(std::ostream &os, const RigidbodyComponent::BodyType &type)
float Interpolate(float current, float previous)
TexturesManager * TEXTURES_MANAGER
The textures manager.
Renderer * RENDERER
The main renderer.