I tumbled across another problem which seems to be quite huge:
I registered an Interface from C++, named 'BaseEntity'.
A script class "AbstractBaseEntity" inherits that Interface.
A script class "AbstractNPC" inherhits "AbstractBaseEntity"
That results in a rather simple class hierarchy...
So far, so good.
I also have registered a method 'instanciate' for a global property named System. It works well, and instanciates my entities just fine. It is registered to return a handle '@BaseEntity' ... which works fine, too.
I can use the InterfaceSpecific methods then.
But now comes the clue:
I cant cast!
The following code does not work:
// Those are self designed includes. They work fine. I made a scriptdump to verify right behavior.
#include scripts/entity/IBaseEntity.as
#include scripts/entity/NPC.as
void main() {
// System pretty sure is registered. But check to be sure...
if( System is null ) {
println("System is null.Aborting.");
return;
}
// Instanciate an entity.
BaseEntity@ ent=System.instanciate("AbstractBaseEntity");
if (ent !is null) {
println("Received Entity(BaseEntity) with id: "+ent.getID());
} else {
println("Ent is null... :'( ");
}
// Prints:
AbstractBaseEntity@ ent2=cast<AbstractBaseEntity>(ent);
if (ent2 !is null)
println("We have an AbstractBaseEntity at hand, btw.");
// Works fine.
ParamList par();
par.addParam("TestNPC");
BaseEntity@ ent3=System.instanciate("AbstractNPC","AbstractNPC @AbstractNPC(int,string)",par);
//ent3 is an BaseEntity by now. Its true. I checked it. (:
AbstractNPC@ ent4=cast<AbstractNPC>(ent);
if (ent4 !is null)
println("We have an AbstractNPC at hand, btw.");
}
Prints:
Received Entity(BaseEntity) with id: 0
AbstractNPC created. ( <- This is printed in the constructor of AbstractNPC )
I just updated to the newst version of angelscript. So far everything seems to work fine.
Help appreciated.
With warm regards,
Kuro Sei.
PS: Shall i have missed some important details or in case you need some closer specification of my registrations or the script classes i will update those asap. But for now i dont see any reasyon why i should pump up this overextended wall of text even more.