Jump to content
  • Advertisement
Sign in to follow this  
BornToCode

Component System

This topic is 2187 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a component based system in my engine. I want to be able to add additional components but through the used of Angelscript. Is that possible since angelscript does not allow you to extend C++ classes which are registered with the scripting engine. Any help would be greatly appreciated. Edited by BornToCode

Share this post


Link to post
Share on other sites
Advertisement
You could create a C++ component which wraps the scripted component inside. The C++ "shell" would forward messages/events, or anything else needed, to the scripted object. Also, you can register specially handled global properties to create the environment for the scripted component, ie. for example how it accesses its parent entity, or the scene.

Share this post


Link to post
Share on other sites
It really depends on how you want the components to work.

It's true that AngelScript script classes cannot inherit from C++ classes, but that doesn't mean a script class cannot provide extended functionality. What can be done is only limited by how much effort you spend on the integration, i.e. the interface between the C++ application and the script application.

How do you want your components to work? If you can provide a few guidelines for what you're looking for I'm sure we can help you figure out how to implement it.

Share this post


Link to post
Share on other sites
I have figure out a way of doing it. I changed my component system to handle asIScriptObject as components. That way when i register an component wit ha game object i can get the pointer from angelscript and assign it to my game object.

Share this post


Link to post
Share on other sites
I have a quick question. I got the id to an construct behaviour. I then execute the construct function through the scriptcontext. Everything went throught fine. Now how do i get the address of the object that was called through the asBEHAVE_CONSTRUCT. I try calling GetReturnObject from the context that execute the code but i keep getting null back. Edited by BornToCode

Share this post


Link to post
Share on other sites
Why are you calling the construct behavior directly? Why not just call asIScriptEngine::CreateScriptObject()?

Share this post


Link to post
Share on other sites
asIObjectType* type = asEngine->GetObjectTypeByName("Vector2");
const char* name = type->GetName();
int typeids = type->GetTypeId();

I keep getting 67057 for the ID. then when i try to allocated memory for the object using the function sicrane metion it just crash.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!