24 std::is_same<T,TagComponent>::value ||
25 std::is_same<T,TextureComponent>::value ||
26 std::is_same<T,AnimatedTextureComponent>::value ||
27 std::is_same<T,RigidbodyComponent>::value ||
28 std::is_same<T,BoxColliderComponent>::value ||
29 std::is_same<T,CircleColliderComponent>::value ||
30 std::is_same<T,LightComponent>::value ||
31 std::is_same<T,NativeScriptComponent>::value ||
32 std::is_same<T,TextComponent>::value,
39template<
typename T,ComponentType<T> = 0>
46 else if(v[m].m_UID<uid)
57template<
typename T,ComponentType<T> = 0>
74template<
typename T,ComponentType<T> = 0>
76 for(
size_t i=v.size()-1;
i>idx;
i--)
105 m_Tag=std::move(b.m_Tag);
117 TextureComponent(
const std::string &path,
int mag_filter,
int min_filter,
float width,
float height,
int layer,uint32_t uid);
118 TextureComponent(std::shared_ptr<Texture>t,
float width,
float height,
int layer,uint32_t uid);
151 AnimatedTextureComponent(
const std::string &path,
unsigned int tile_width,
unsigned int tile_height,
int mag_filter,
int min_filter,
float width,
float height,
int layer,
bool play_animation,
bool loop_animation,
float animation_delay,
int animation_index,uint32_t uid);
152 AnimatedTextureComponent(std::shared_ptr<SpriteSheet>t,
float width,
float height,
int layer,
bool play_animation,
bool loop_animation,
float animation_delay,
int animation_index,uint32_t uid);
268 void SetOffset(
float x_offset,
float y_offset);
293 TextComponent():
m_TextRenderer(std::make_shared<
TextRenderer>()),
m_Text(100,
'\0'),
m_Offset(0.0f,0.0f),
m_Color(1.0f,1.0f,1.0f),
m_Scale(1.0f),
m_Layer(0),
m_IgnoreLighting(false),
m_UID(std::numeric_limits<uint32_t>::max()){}
294 TextComponent(uint32_t uid):
m_TextRenderer(std::make_shared<
TextRenderer>()),
m_Text(100,
'\0'),
m_Offset(0.0f,0.0f),
m_Color(1.0f,1.0f,1.0f),
m_Scale(1.0f),
m_Layer(0),
m_IgnoreLighting(false),
m_UID(uid){}
295 TextComponent(std::shared_ptr<TextRenderer> textRenderer,
const std::string &text,
Vec2 offset,
Vec3 color,
float scale,uint32_t uid):
300 TextComponent(
const std::string &path,
float glyph_size,
bool fixed,
const std::string &text,
Vec2 offset,
Vec3 color,
float scale,
int layer,
bool ignore_lighting,uint32_t uid):
342 int l=0,r=v.size()-1;
347 else if(v[m].m_UID<uid)
355template<
typename T,ComponentType<T> = 0>
376 if constexpr(std::is_same<T,RigidbodyComponent>::value)
378 if constexpr(std::is_same<T,BoxColliderComponent>::value)
380 if constexpr(std::is_same<T,CircleColliderComponent>::value)
434 return b2_staticBody;
436 return b2_dynamicBody;
438 return b2_kinematicBody;
440 return b2_staticBody;
452 case b2_kinematicBody:
455 printf(
"Unknown body type\n");
AnimatedTextureComponent()
AnimatedTextureComponent & operator=(AnimatedTextureComponent &b)
AnimatedTextureComponent(uint32_t uid)
void PlayAnimation(bool loop=false, float delay=0.0f)
float m_LastAnimationTime
std::shared_ptr< SpriteSheet > m_AnimatedTexture
AnimatedTextureComponent & operator=(AnimatedTextureComponent &&b)
BoxColliderComponent(float x_offset, float y_offset, float width, float height, float density, float friction, float restitution, float restitution_threshold, uint32_t uid)
float m_RestitutionThreshold
b2Fixture * m_RuntimeFixture
BoxColliderComponent(uint32_t uid)
CircleColliderComponent()
b2Fixture * m_RuntimeFixture
CircleColliderComponent(uint32_t uid)
float m_RestitutionThreshold
CircleColliderComponent(float x_offset, float y_offset, float radius, float density, float friction, float restitution, float restitution_threshold, uint32_t uid)
T * GetComponent(uint32_t uid)
void Render(Scene *scene)
void AddComponent(T &component, uint32_t uid)
Rect * GetComponentAsRect(int index)
std::vector< T > m_Components
void RemoveComponent(uint32_t uid)
void Update(Scene *scene, float frame_time)
std::vector< T > & GetComponents()
Entity & operator=(const Entity &other)
void SetOffset(float x_offset, float y_offset)
void SetCentered(float width, float height)
std::function< void(Scene *, NativeScriptComponent *) OnDestroy)
NativeScriptComponent(uint32_t uid)
std::function< void(Scene *, NativeScriptComponent *, float) OnUpdate)
std::function< void(Scene *, NativeScriptComponent *) OnCreate)
RigidbodyComponent(BodyType bodyType, bool fixedRotation, uint32_t uid)
RigidbodyComponent(uint32_t uid)
TagComponent & operator=(TagComponent &&b)
TagComponent & operator=(TagComponent &b)
TagComponent(const std::string &tag, uint32_t uid)
TextComponent(std::shared_ptr< TextRenderer > textRenderer, const std::string &text, Vec2 offset, Vec3 color, float scale, uint32_t uid)
TextComponent(const std::string &path, float glyph_size, bool fixed, const std::string &text, Vec2 offset, Vec3 color, float scale, int layer, bool ignore_lighting, uint32_t uid)
TextComponent & operator=(const TextComponent &other)
std::shared_ptr< TextRenderer > m_TextRenderer
TextComponent(uint32_t uid)
TextComponent(const std::string &path, float glyph_size, bool fixed, uint32_t uid)
void SetCentered(float width, float height)
TextureComponent & operator=(TextureComponent &&b)
TextureComponent & operator=(TextureComponent &b)
std::shared_ptr< Texture > m_Texture
TextureComponent(uint32_t uid)
int FirstGreaterThan(std::vector< T > &v, uint32_t uid)
RigidbodyComponent::BodyType RigidbodyTypeFromBox2DBody(b2BodyType bodyType)
int BinarySearch(std::vector< T > &v, uint32_t uid)
float Interpolate(float current, float previous)
void RightShift(std::vector< T > &v, size_t idx)
typename std::enable_if< std::is_same< T, TagComponent >::value|| std::is_same< T, TextureComponent >::value|| std::is_same< T, AnimatedTextureComponent >::value|| std::is_same< T, RigidbodyComponent >::value|| std::is_same< T, BoxColliderComponent >::value|| std::is_same< T, CircleColliderComponent >::value|| std::is_same< T, LightComponent >::value|| std::is_same< T, NativeScriptComponent >::value|| std::is_same< T, TextComponent >::value, int >::type ComponentType
b2BodyType RigidbodyTypeToBox2DBody(RigidbodyComponent::BodyType bodyType)
std::ostream & operator<<(std::ostream &os, const RigidbodyComponent::BodyType &type)
FontManager * FONT_MANAGER
The font manager.