![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
Base class for all tasks. More...
#include <C_task.hpp>
Public Member Functions | |
virtual fge::TaskResult | update (fge::TaskHandler &taskHandler, fge::Event &event, std::chrono::microseconds const &deltaTime, fge::Scene *scenePtr)=0 |
Update the task. | |
virtual fge::TaskTypeIndex | getTypeIndex () const =0 |
Get the type index of the task. | |
virtual std::string_view | getStringStatus () const =0 |
Get the custom status of the task as a string. | |
float | getProgression () const |
Get the progression of the task as a percentage. | |
virtual void | pack (fge::net::Packet &pck)=0 |
Pack the task data into a packet. | |
virtual void | unpackAndInit (fge::net::Packet const &pck)=0 |
Unpack the task data from a packet and initialize the task. | |
fge::Object * | getParentObject () const |
Get the parent object of the task. | |
template<class T > | |
T * | getParentObject () const |
Protected Attributes | |
float | _g_progress {0.0f} |
Friends | |
class | TaskHandler |
class | NetworkTypeTasks |
Base class for all tasks.
A Task represent an action that can be done by an object. An action can be composed of multiple sub-tasks.
When inheriting from this class, you should implement a init() method that will initialize the task with custom parameters.
This class can also be network aware.
|
inlinenodiscard |
Get the parent object of the task.
This is always an object that should generally contain the TaskHandler.
|
inlinenodiscard |
Get the progression of the task as a percentage.
|
nodiscardpure virtual |
Get the custom status of the task as a string.
|
nodiscardpure virtual |
Get the type index of the task.
Every task must have a unique type index that can be retrieved using the task_manager.hpp functions.
|
pure virtual |
Pack the task data into a packet.
pck | The packet |
|
pure virtual |
Unpack the task data from a packet and initialize the task.
pck | The packet |
|
pure virtual |
Update the task.
In order to complete a task, it must be updated.
This function can return multiple values:
When receiving ERROR, all tasks from the TaskHandler should be cleared by calling TaskHandler::clearTasks(). When receiving FINISHED, the top task should be removed by calling TaskHandler::popTask().
taskHandler | The TaskHandler that handle this task |
event | The event object |
deltaTime | The time elapsed since the last update |
scenePtr | The scene pointer |