-
Notifications
You must be signed in to change notification settings - Fork 0
Quest Factories
Factories are a way to generate quests procedurally, based on potentially unknown data. For example, a factory may scan for items matching a given pattern, or they may generate quests for items that are impossible to represent normally (bees).
In all cases, quest factories must implement the IQuestFactory
interface. How to do this is beyond the scope of this document, which is going to focus on configuration only.
Once you have a class defined for the Factory, it must be referenced in a quest file, like normal quests. This may be done in two ways:
{
"factories": [
"com.mike_caron.megacorp.impl.quests.Forestry$Tubes",
{
"class": "com.mike_caron.megacorp.impl.quests.Forestry$Tubes"
}
],
...
}
The string notation may be used if the factory doesn't need any additional data. The object notation must be used if you need to provide additional data (which will vary based on the factory's implementation).
Let's suppose the factory needs a list of materials as an array. That might look like this:
{
"factories": [
{
"class":"whatever.MyFactory",
"materials": [
"Iron",
"Gold",
"Diamond"
]
}
]
}
However, you might find that you have several factories that all need the same list. In this case, you may factor the list out into a constant:
{
"factories": [
{
"class":"whatever.MyFactory",
"materials": "#mymaterials"
},
{
"class":"whatever.AnotherFactory",
"materials": "#mymaterials"
}
],
"constants": {
"mymaterials": [
"Iron",
"Gold",
"Diamond"
]
}
}
There is a secondary benefit to this: You may add on to that constant in other files. This is particularly useful for built in quests and their factories, which you can't modify directly. Pretend the above definition was built in, and you wanted to add Bronze
to the list. Just specify this in your custom quest file:
{
"constants": {
"mymaterials" [
"Bronze"
]
}
}
And the list will be merged together.
Note that constants are globally scoped, and so if you create your own constants, make sure to give them unique names (like "custom.mylist" or whatever).