hmm...
this making a comment and checking with a script if the property is added to Lua and AI interface...
it is simple, but would help in only one aspect: we would more likely be exporting all props that are meant to be exported.
it would not make management and accessing properties more unified eg.
also... i see it happening like this:
somoene adds a property, compiles spring, and uses it, not even noticing the wrarnings, and someone later an other dev would have to go through the wranings and try to find out if the prop is usefull for Lua and/or AI, and add code to export it. i would not like to be that dev.
otherwise, the guy adding the property would have to add a line somewhere that contains everything needed anyway (eg name, type, description, flags (AI | LUA | ...)).
i still think having something like a WorldObjectWithProperties solution is the best way to go. it is not hacky at all, has all the pros, and .. if its not the speed, then i dont know what contra.
it would be like this:
UnitDef.cpp:
Code: Select all
UnitDef::UnitDef() {
this.addProperty(PROP_IDX_NAME, "name", "EMPTY", AI_EXPORT | LUA_EXPORT, "The name of this type of unit");
this.addProperty(PROP_IDX_MODEL, "modelId" 0, LUA_EXPORT, "The graphical representation of this unit type");
...
}
in the mod:
Code: Select all
...
unitDef[x].addProperty(hyperSpaceSpeed, 1000, AI_EXPORT | LUA_EXPORT, "The of this unit tpe when flying in hyper-space");
...
in an AI:
Code: Select all
...
unitDef[x].listAllProperties();
...
output:
Code: Select all
name, "spaceFighter", AI_EXPORT | LUA_EXPORT, "The name of this type of unit"
hyperSpaceSpeed, 1000, AI_EXPORT | LUA_EXPORT, "The of this unit tpe when flying in hyper-space"
the details in this example are not correct (like property indices and name handling and such). its just meant as an intro to the idea in general.