-
Notifications
You must be signed in to change notification settings - Fork 15
API
The QuestSystem
class is the main entrypoint to the Quest API.
It handles all the [quest pools] and also provide helpers to add more pools or manage your quest resource.
Name | Type | Description |
---|---|---|
available |
AvailableQuestPool | Reference to the default "available pool" |
active |
ActiveQuestPool | Reference to the default "active pool" |
completed |
CompletedQuestPool | Reference to the default "completed pool" |
Name | Return Type |
---|---|
start_quest(quest: Quest) | Quest |
complete_quest(quest: Quest) | Quest |
mark_quest_as_available(quest: Quest) | void |
get_available_quests() | Array[Quest] |
get_active_quests() | Array[Quest] |
is_quest_available(quest: Quest) | bool |
is_quest_active(quest: Quest) | bool |
is_quest_completed(quest: Quest) | bool |
call_quest_method(quest_id: int, method: String, args: Array) | void |
add_new_pool(pool_path: String, pool_name: String) | void |
move_quest_to_pool(quest: Quest, old_pool: String, new_pool: String) | Quest |
quests_as_dict() | Dictionary |
dict_to_quests(dict: Dictionary, quests: Array[Quest]) | void |
serialize_quests(pool: String) | Dictionary |
signal | description |
---|---|
quest_accepted(quest: Quest) | Emitted when a quest gets moved to the ActivePool |
quest_completed(quest: Quest) | Emitted when a quest gets moved to the CompletedPool |
new_available_quest(quest: Quest) | Emitted when a quest gets added to the AvailablePool |
Starts a given quest by calling its start() method and moving it from the available pool to the active pool.
Can be called even if the quest is not in the available pool.
If the quest is already in the active pool or in the complete pool, it won't do nothing and returns back the quest.
It also emits the quest_accepted signal
Stops a given quest by calling its complete() method and moving it from the active pool to the completed pool.
If the quest is not in the active pool, it won't do nothing and returns back the quest.If the objective_completed property of the quest is not set to true when the complete() method gets called, it will not mark the quest as completed and instead return back the quest object.
It also emits the quest_completed signal
void mark_quest_as_available(quest: Quest)
Adds a quest to the available pool if not already present in any of the default pools
It also emits the new_available_quest signal
Returns all quests in the available pool
Returns all quests in the active pool
Checks if the given quest is inside the avaiable pool. Returns
true
if the quest is found.
Checks if the given quest is inside the active pool. Returns
true
if the quest is found.
Checks if the given quest is inside the completed pool. Returns
true
if the quest is found.
Calls any given method inside a specific quest without the need to have a direct reference to the Quest Resource.
You will need to provide the ID of the quest and the method name.
You can also provide additional arguments to the function.
If the quest is not found, it won't do anything. Internally thecallv
function gets used
Adds a custom quest pool.
You'll need to reference the path of a Script that inherits BaseQuestPool forpool_path
and give the pool a name.
Forcefully move a quest from a pool to another
Dictionary quests_as_dict()
Returns a dictionary with all the quest pools and their respectively quests referenced by their id.
{ "available": [5], "active": [1, 2, 3], "completed": [4], }
void dict_to_quests(dict: Dictionary, quests: Array[Quest])
Loads back into the pools the given quest resources based on a dictionary as the one that quest_as_dict() returns.
If a pool in the dictionary is not present in the QuestSystem children, it gets skipped.
Dictionary serialize_quests(pool: String)
Serialize all the properties of the quests of a pool and returns them as a dictionary.
{ "1": { "quest_name": "Test Quest", "quest_description": "This is the description of the test quest.", "quest_objective": "Nothing.", "objective_completed": false } }If a quest has custom properties they will also get serialized.
Base class for all Quest resources.
By itself it does nothing other than provide a simple API to make quests.
To make a custom quest make a script that inherits Quest
and implement your own logic, then create a Resource of the type of your custom quest.
Note: you should implement the start() and complete() methods and set the objective_completed
property to true to make the quest completable.
(These are the default properties that every quest resource share. You can add your custom properties in a custom quest resource.)
Name | Type | Description |
---|---|---|
id |
int | Unique Identifier for a quest |
quest_name |
String | The name of a quest |
quest_description |
String | Description of the quest |
quest_objective |
String | Description of the objective of the quest |
objective_completed = false
|
bool | Tracks the progress of the quest. If it's false, the quest can't be moved to the CompletedPool |
Name | Return Type |
---|---|
start() | void |
complete() | **void |
Gets called after start_quest
Gets called after complete_quest only if
objective_completed
is set totrue
BaseQuestPool
(pool_name: String
)
Base class for all quest pools.
Inherit this class to make a custom pool with your own logic.
You need to pass a name to give to the pool in the constructor of the class.
Name | Type | Description |
---|---|---|
quests | Array[Quest] | An array of all the quests in the pool |
Name | Return Type |
---|---|
add_quest(quest: Quest) | Quest |
remove_quest(quest: Quest) | Quest |
get_quest_from_id(id: int) | Quest |
is_quest_inside(quest: Quest) | bool |
Adds a quest resource into the quests array
Removes a quest resource into the quests array
Returns a quest with the corresponding id.
If no quest gets found,null
is returned instead
Returns
true
if a given quest is inside the pool.
Container for all available quests. Inherits BaseQuestPool
Container for all active quests. Inherits BaseQuestPool
Container for all completed quests. Inherits BaseQuestPool