-
Notifications
You must be signed in to change notification settings - Fork 1
Description
In order to provide a more powerful way of extending this game, I'd like to introduce you to a new way of defining modules in Galacticum. By doing so it is pretty easy to extend the game without knowing other classes.
Example
Let's thing about an AI module, which alters AI logic to the existing game. This is the basic structure:
@GameModule(dependsOn = { EntityModule.class, FooBar.class })
public class StupidAIModule implements Module, WorldListener {
// Requires a default constructor!
public StupidAIModule() { /* ... */ }
@Override
public void start(Context context) {
// Load things here
}
@Override
public void update(float delta) {
// Update behavior here
}
@Override
public void onAddEntity(Entity entity) {
// Invoke AI behavior to the entity, if it's an enemy
}
@Override
public void onRemoveEntity(Entity entity) {
// Remove behavior from the entity if exists
}
}That's it! You don't need to take care of how this system will be created or managed.
Annotations
As you can see, there are annotations at top of the class. @GameModule flags the class as an active module which will be created by the game automatically. You can define dependencies of the module, for instance, if you have a lighting system which depends on a physics system you want to ensure that the physics will be initalized even before the lighting part. You can pass an array of classes to specify dependencies.