libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
task.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include <dantelion2/text.hpp>
11#include <detail/preprocessor.hpp>
12#include <fd4/component.hpp>
17
18#include <algorithm>
19#include <span>
20#include <string>
21
22namespace from {
23namespace CS {
31using cstgi = unsigned int;
32
33// Forward declaration
34class CSEzTaskProxy;
35
51class CSEzTask : public FD4::FD4TaskBase {
52public:
53 FD4_RUNTIME_CLASS(CSEzTask);
54
55 CSEzTask() = default;
56
57 virtual ~CSEzTask() {
58 this->free_task();
59 }
60
70 void execute(FD4::FD4TaskData* data) final {
71 this->eztask_execute(data);
72 }
73
83 virtual void eztask_execute(FD4::FD4TaskData* data) = 0;
84
97 LIBERAPI virtual void register_task(CSTaskGroup task_group);
98
109 LIBERAPI virtual void free_task();
110
116 LIBERAPI CSTaskGroup get_task_group() const noexcept;
117
118private:
123 CSEzTaskProxy* proxy = nullptr;
124};
125
131class CSEzTaskProxy : public FD4::FD4TaskBase {
132public:
133 FD4_RUNTIME_CLASS(CSEzTaskProxy);
134
140 LIBERAPI void execute(FD4::FD4TaskData* data) override;
141
147 virtual CSTaskGroup get_task_group() const noexcept {
148 return this->task_group;
149 }
150
151private:
152 CSEzTask* owner;
153 CSTaskGroup task_group;
154};
155
161public:
162 LIBER_CLASS(EzChildStepBase);
163
164 virtual ~EzChildStepBase() = default;
165
166private:
167 CSEzTask* task = nullptr;
168 bool run = false;
169 void* liber_unknown;
170};
171
172class CSTask;
173
179public:
180 FD4_SINGLETON_CLASS(CSTaskImp);
181
182 virtual ~CSTaskImp() LIBER_INTERFACE_ONLY;
183
193 if (!this->inst)
194 return std::nullopt;
195 return *this->inst;
196 }
197
198private:
199 CSTask* inst;
200};
201
207 struct cstg_control {
208 cstg_control(cstgi id, bool active) : id(id), active(active) {}
209
210 cstgi id;
211 wchar_t name[64]{};
212 bool active;
213 };
214
215public:
216 virtual ~CSTaskBase() LIBER_INTERFACE_ONLY;
217
218 from::allocator<void> liber_unknown;
219
228
234};
235
242class CSTask : private CSTaskBase {
243public:
244 LIBER_INTERFACE_CLASS(CSTask);
245
246 virtual ~CSTask() LIBER_INTERFACE_ONLY;
247
253 const auto& get_task_groups() const noexcept {
254 return this->task_groups;
255 }
256
257private:
258 virtual void add_task_group(const wchar_t* name) LIBER_INTERFACE_ONLY;
259 virtual bool unk_set_task_group(cstgi) LIBER_INTERFACE_ONLY;
260 virtual bool set_task_group_state(cstgi id,
261 bool state) LIBER_INTERFACE_ONLY;
262 virtual void debug_print() LIBER_INTERFACE_ONLY;
263 virtual void queue_tasks(void* unk1, void* unk2) LIBER_INTERFACE_ONLY;
264
265 from::allocator<void> liber_unknown;
266 void* liber_unknown[8];
267 void* task_seeds_0x30[6];
268 void* task_seeds_0x60[6];
269 bool liber_unknown;
270};
271
272LIBER_ASSERTS_BEGIN(CSTask);
273LIBER_ASSERT_SIZE(0xE8);
274LIBER_ASSERTS_END;
275} // namespace CS
276} // namespace from
An internal proxy object for CS::CSEzTask instances inside ELDEN RING's task management system.
Definition task.hpp:131
virtual CSTaskGroup get_task_group() const noexcept
Get the task group this proxy was registered at.
Definition task.hpp:147
LIBERAPI void execute(FD4::FD4TaskData *data) override
Executes the proxied task.
Inherit from this minimal task interface to create a custom task.
Definition task.hpp:51
LIBERAPI CSTaskGroup get_task_group() const noexcept
Get the task group this task is currently registered at.
void execute(FD4::FD4TaskData *data) final
FD4::FD4TaskBase execute method that calls eztask_execute.
Definition task.hpp:70
virtual LIBERAPI void free_task()
Free the task, suspending its execution after it has been registered.
virtual LIBERAPI void register_task(CSTaskGroup task_group)
Register a task to be called in a specified task group.
virtual void eztask_execute(FD4::FD4TaskData *data)=0
Virtual method that is called when a CS::CSEzTask is executed.
Base of CS::CSTask.
Definition task.hpp:206
cstgi task_group_count
The total count of all task groups.
Definition task.hpp:233
from::vector< cstg_control > task_groups
A vector of structures that describe every task group.
Definition task.hpp:227
The only way the CS::CSTask singleton can be accessed.
Definition task.hpp:178
liber::optref< CSTask > get() noexcept
Get the associated CSTask instance.
Definition task.hpp:192
The main namespace CS task interface.
Definition task.hpp:242
const auto & get_task_groups() const noexcept
Get every task group.
Definition task.hpp:253
A child task executed by tasks and steppers in ELDEN RING.
Definition task.hpp:160
The base task interface.
Definition fd4_task.hpp:101
The main libER stand-in for ER allocator proxies.
Definition from_allocator.hpp:310
FD4ComponentBase implementation.
Namespace FD4 task interface.
ELDEN RING allocation interface and from::allocator.
from::vector based on std::vector
std::vector< T, from::allocator< T, AllocatorTag > > vector
std::vector with from::allocator.
Definition from_vector.hpp:23
FD4_SINGLETON_CLASS implementation.
The data passed to tasks on execution.
Definition fd4_task.hpp:55
A std::optional<std::reference_wrapper<T>> wrapper for lvalue references.
Definition optref.hpp:31
unsigned int cstgi
Typedef of a special unsigned integer type that may represent a task id.
Definition task.hpp:31
CSTaskGroup
Enum of all tasks, in order of their execution.
Definition taskgroups.inl:13
Dantelion2 strings.