@@ -36,9 +36,16 @@ namespace OverEngine
3636 entity.GetComponent <TransformComponent>().SetPosition (position);
3737 }
3838
39- // TODO: Move into component classes (not all entities have rigidbodies)
40- // TODO: Use Vector2
41- void EntityInternals_applyLinearImpulseToCenter (Entity& entity, const Vector3& impulse)
39+ #define COMPONENT_HAS (component ) \
40+ bool component##_has(Entity& entity) \
41+ { \
42+ return entity.HasComponent <component>(); \
43+ }
44+
45+ COMPONENT_HAS (TransformComponent)
46+ COMPONENT_HAS (RigidBody2DComponent)
47+
48+ void RigidBody2DComponent_applyLinearImpulseToCenter (Entity& entity, const Vector3& impulse)
4249 {
4350 entity.GetComponent <RigidBody2DComponent>().RigidBody ->ApplyLinearImpulseToCenter (impulse);
4451 }
@@ -59,14 +66,26 @@ namespace OverEngine
5966 WRENPP_BIND_STATIC (EntityInternals_getName, " getName(_)" )
6067 WRENPP_BIND_STATIC (EntityInternals_getPosition, " getPosition(_)" )
6168 WRENPP_BIND_STATIC (EntityInternals_setPosition, " setPosition(_,_)" )
62-
63- WRENPP_BIND_STATIC (EntityInternals_applyLinearImpulseToCenter, " applyLinearImpulseToCenter(_,_)" )
6469 .endClass ()
6570
6671 .bindClass <Entity>(" Entity" )
6772 .endClass ()
6873 .endModule ();
6974
75+ m_VM.beginModule (" components" )
76+ .beginClass (" ComponentInternals" )
77+ WRENPP_BIND_STATIC (RigidBody2DComponent_applyLinearImpulseToCenter, " RigidBody2DComponent_applyLinearImpulseToCenter(_,_)" )
78+ .endClass ()
79+
80+ .beginClass (" TransformComponent" )
81+ WRENPP_BIND_STATIC (TransformComponent_has, " has(_)" )
82+ .endClass ()
83+
84+ .beginClass (" RigidBody2DComponent" )
85+ WRENPP_BIND_STATIC (RigidBody2DComponent_has, " has(_)" )
86+ .endClass ()
87+ .endModule ();
88+
7089 m_VM.beginModule (" math" )
7190 .bindClass <Vector3, float , float , float >(" Vector3" )
7291 WRENPP_BIND_GETTER (Vector3::x, " x" )
0 commit comments