openage nyan library
The openage engine defines all kinds of
NyanObject s so the nyan interpreter can verify data integrity. Together, the defined objects provide the API that can be used by the games running on the engine.
This interface will be described here.
In addition to the nyan design goals, the openage mod API follows its own design principles. It is recommended to follow these principles when extending the API.
Single API tree
The API objects and every additional defined object are part of the same inheritance tree. To ensure this, all objects must inherit from the root object
Entity , either explicitely or implicitely through its parents. By doing this, we can maintain a consistent object hierarchy, even if several mods are activated.
Define game entities through abilities
Game entities are nyan objects that are visibly present in the game world (e.g. units or buildings). Their data will mostly be defined by nested objects inheriting from
Ability . An
Ability object is basically a capsule for data and corresponds to an engine function. Therefore, abilities indirectly define what a unit can do (attack, gather, move, etc.) or what i can be (constructable, selectable, etc.). During a game, the corresponding engine function then decides how the data is going to be used.
No replacement of game entities within their life cycle
In AoE2, game objects’ attributes are mostly static and cannot represent different states. For example, tree objects are replaced with tree stump objects when they are chopped down by villagers, empty trade carts are replaced with full trade carts once they reach a market and villager objects change when they are assigned to a different resource spot. Because nyan objects can dynamically change at runtime, this strategy becomes unfeasible as it becomes increasingly difficult to determine a consistent target state. Instead, abilities will be used for modelling the various states a nyan object has. There also exists the possibility to model game entities as state machines.
No reliance on inheritance for specialization
Inheritance cannot be removed from an object, so we have to be careful when introducing it to the API. Instead of inheritance an entity-component model is utilized, e.g. for abilities and modifers. If inheritance is used, it should follow these principles:
- Avoid multi-inheritance in the API tree
- Make it possible to configure the inherited members in such a way that the non-specialized behavior can be replicated
Genie engine functionality ⊆ nyan API functionality
The functionality of Genie Engine abilities should always be a subset of the functionality of the openage API. Hardcoding should be removed and integrated into existing abilities.
An overview of the API design for the data of Age of Empires 2 is available as an UML diagram.