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
10
namespace
red
{
11
12
/**
13
* @brief Builder for replacing a vanilla profile with a custom one by its numeric ID.
14
* @tparam T Actor class that the profile will now instantiate.
15
*/
16
template
<
class
T
>
requires
std
::
derived_from
<
T
,
ActorBase
>
17
class
ProfileReplaceBuilder
:
public
ProfileBuilder
<
ProfileReplaceBuilder
<
T
>> {
18
public
:
19
/**
20
* @brief Begins replacing a vanilla profile.
21
* @param id The target profile ID to replace.
22
*/
23
explicit
ProfileReplaceBuilder
(
s32
id
)
24
:
ProfileBuilder
<
ProfileReplaceBuilder
<
T
>>()
25
,
mID
(
id
)
26
{
27
if
(
id
>
ProfileInfo
::
cProfileID_Max
) {
28
tk
::
fatal
(
"ERROR: Attempting to replace invalid vanilla profile ID: %i"
,
id
);
29
}
30
}
31
32
/**
33
* @brief Completes the builder by replacing the vanilla profile.
34
* @return The profile which now contains the replaced data.
35
*/
36
Profile
*
build
() {
37
if
(
mID
>
ProfileInfo
::
cProfileID_Max
) {
38
return
nullptr
;
39
}
40
41
pub
::
Profile
*
profile
=
static_cast
<
pub
::
Profile
*>(
Profile
::
get
(
mID
));
42
43
profile
->
mFactory
= &
TActorFactory
<
T
>;
44
profile
->
mActorCreateInfo
=
this
->
mCreateInfo
!=
nullptr
?
this
->
mCreateInfo
: &
ActorCreateInfo
::
cDefault
;
45
profile
->
mIsResLoaded
=
false
;
46
profile
->
mFlag
=
this
->
mFlag
;
47
48
ProfileEx
::
setExecutePriority
(
mID
,
this
->
mExecutePriority
);
49
50
return
profile
;
51
}
52
53
private
:
54
s32
mID
;
///< The target profile ID to replace.
55
};
56
57
}
red
Definition
ActorDonutBlock.h:5
include
red
registry
builder
ProfileReplaceBuilder.h
Generated by
1.14.0