I'm implementing a Entity Component System in AngelScript, suppose we have the following classes
abstract class Component { }
class Position : Component { float x; float y; }
class Velocity : Component { float vel; }
Then we have an entity that holds Component objects, currently I'm associating a number to the components and doing the following to retrieve them.
Velocity@ vel = cast<Velocity>(entity.getComponent(VelocityIdx));
There is a way in AngelScript side to define a template function? I want to instead doing something like.
Velocity@ vel = entity.getComponent<Velocity>();
//or maybe something like
Velocity@ vel = entity.getComponent(Velocity.class);
Or there is any way to avoid casting each time when retrieving a component?
Thanks in advance.