I have a few different C++ classes in my game, that can interact. "Props" like exploding barrels, vending machines, "Doors", "Lights" and "SoundSources". Each object shall react on certain events (being clicked, being "used" by a player, ...). To describe the object's internal states and reactions I'd like to use an angelscript class. For a vending machine it can hold data for the cans left, and the amount of money it has received. It should also be able to add a coke can to the player's inventory, via a line like this: player.add(createItem("coke can"));
An instance of the angelscript class is assigned to the actual C++ instance. Events are processed by calling a method of the as instance, which can only access other as instances (the c++ classes are not exposed). AS classes are derived from a base class. For example class VendingMachine : Prop { ... }
Subclasses only need to interact with the base classes. During the course of the game new objects may be created. A flare "Item" class could for example spawn a new "Light" class. This light is loaded on the fly and it may use a sub class of "Light" that is not yet built into the module.
Currently adding new objects is only possible if ALL classes, that MAY be used, are built in a single build call. I'd like to add new classes only when an object is loaded that uses a class not yet built into the module.
I hope I could clarify my problem. If there is an easier way to achieve this, please enlighten me. :)