Sign in to follow this  
3DModelerMan

Interfaces and base classes

Recommended Posts

I'm trying to register a component system with AngelScript for my engine right now I have a C++ component that wraps an AngelScript object. It basically just calls the matching methods on the AngelScript object whenever the function is called in C++, so when the C++ update() method gets called the AngelScript object instance's update() method is called as well. What I want is for all the components to derive from a base component class that contains a reference to the owner game object. On the C++ side i have an IComponent interface. If I register the IComponent interface as a reference type is there any way to register my C++ IComponent implementations as being derived from the AngelScript component base class? 

Share this post


Link to post
Share on other sites

No, a C++ class cannot derive from a script class, neither can a script class derive from a C++ class.

 

You can however provide a shared AngelScript component base class that implements the desired binding mechanism to tie the script class to the C++ class. This shared class can then be derived by all the custom components.

Share this post


Link to post
Share on other sites
Yes and no. There's no explicit method in the registration interface to specify that two classes are specifically related by inheritance. However, you can register implicit and explicit cast behaviors. You can register an implicit cast from derived to base and an explicit cast from base to derived and that usually takes care of all your needs for the relation between base and derived classes. See the manual on class hierarchy.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this