RedCore
Loading...
Searching...
No Matches
ProfileReplaceBuilder.h
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4
5#include <actor/ProfileInfo.h>
6#include <actor/Actor.h>
7#include <red/registry/builder/ProfileBuilder.h>
8#include <red/public/Profile.h>
9#include <red/profile/ProfileEx.h>
10#include <red/event/StaticInitEvent.h>
11#include <telkin/Privilege.h>
12
13namespace red {
14
15/**
16 * @brief Builder for replacing a vanilla profile with a custom one by its numeric ID.
17 * @tparam T Actor class that the profile will now instantiate.
18 * @tparam ID The target profile ID to replace.
19 */
20template <class T, s32 ID> requires std::derived_from<T, ActorBase>
22public:
23 static_assert(ID <= ProfileInfo::cProfileID_Max, "ERROR: Attempting to replace an invalid vanilla profile ID.");
24
28
29 /**
30 * @brief Completes the builder by replacing the vanilla profile.
31 * @return The profile which now contains the replaced data.
32 */
34 static bool instantiated = false;
35 if (instantiated) {
36 tk::fatal("Cannot reuse the same template instanciation for two replacements.");
37 }
38 instantiated = true;
39
40 // defer until the vanilla profile is inited so we have the final say
41 static const struct {
49 } sSnapshot = {
50 .mCreateInfo = this->mCreateInfo,
51 .mFlag = this->mFlag,
54 .mResources = this->mResources,
57 };
58
60 pub::Profile* profile = static_cast<pub::Profile*>(Profile::get(ID));
61
64 profile->mIsResLoaded = false;
66
71
73 });
74
75 return ProfileEx::get(ID);
76 }
77};
78
79}
Definition ActorDonutBlock.h:5