NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_actorcreate_manager.hpp
1#pragma once
2
3#include <game/bases/d_actor.hpp>
4#include <game/bases/d_actor_data.hpp>
5#include <game/bases/d_cd.hpp>
6#include <game/mLib/m_vec.hpp>
8
9#define GROUP_ID(param) (param >> 24)
10
11/// @unofficial
13 enum BOUND_SCROLL_DIR_X_e {
14 BOUND_SCROLL_X_RIGHT = -1,
15 BOUND_SCROLL_X_LEFT,
16 BOUND_SCROLL_X_NONE,
17 };
18
19 enum BOUND_SCROLL_DIR_Y_e {
20 BOUND_SCROLL_Y_DOWN = -1,
21 BOUND_SCROLL_Y_UP,
22 BOUND_SCROLL_Y_NONE,
23 };
24
25 int mScrollBoundaryTileX, mScrollBoundaryTileY;
26 int mTileLeft, mTileRight, mTileTop, mTileBottom;
27 BOUND_SCROLL_DIR_X_e mScrollDirX;
28 BOUND_SCROLL_DIR_Y_e mScrollDirY;
29};
30
31/// @brief Manager for map actor creation.
32/// @decompnote{Map actors are the equivalent of sprites in Reggie terminology.}
33/// @ingroup bases
35public:
36 void ActorCreateInfoClear(); ///< Resets all temporary data for map actor spawning.
37
38 /**
39 * @brief Checks whether an actor should be spawned based on the camera's current scroll position.
40 * @details This check succeeds if the actor spawn area's edge lies exactly on the screen
41 * boundary's edge and the area overlaps with the boundary on the perpendicular axis.
42 * @param boundsEdge The coordinate of the screen boundary edge (on the axis of movement), in tiles.
43 * @param areaEdge The coordinate of the actor's corresponding spawn area edge, in tiles.
44 * @param boundMin The minimum coordinate of the boundary on the perpendicular axis, in tiles.
45 * @param boundMax The maximum coordinate of the boundary on the perpendicular axis, in tiles.
46 * @param areaMin The minimum coordinate of the spawn area on the perpendicular axis, in tiles.
47 * @param areaMax The maximum coordinate of the spawn area on the perpendicular axis, in tiles.
48 * @returns @p true if the actor should be spawned, @p false otherwise.
49 */
50 bool ScroolAreaInCheck(int boundsEdge, int areaEdge, int boundMin, int boundMax, int areaMin, int areaMax);
51
52 /// @brief Checks whether an actor should be spawned due to being close to a screen edge (for looping stages).
53 /// @note In the current implementation, this is a direct wrapper for ScroolAreaInCheck().
54 bool ScroolAreaInLoopCheck(int boundsEdge, int areaEdge, int boundMin, int boundMax, int areaMin, int areaMax);
55
56 void setMapActorCreate(); ///< Initializes map actors on first area load.
57 void setMapActorCreate_next(); ///< Initializes map actors on area reload.
58 void MapActorInital_set(); ///< Triggers actor creation on first area load.
59 void MapActorInital_next(); ///< Triggers actor creation on area reload.
60
61 /// @brief Checks whether the profile associated to the map actor is allowed to ignore screen bounds on spawn.
62 /// @unofficial
63 /// @returns @p true if the actor is in the "global" whitelist.
65
66 /**
67 * @brief Adds a group-based map actor to the group manager.
68 * @unofficial
69 * @param data The map actor to be added.
70 * @param file The course file the map actor is in.
71 * @param mapActorIdx The index of the map actor in the level data.
72 */
73 void processGroupId(sMapActorData *data, u8 file, u32 mapActorIdx);
74
75 /// @brief Checks whether the provided actor parameters contain a group ID definition.
76 /// @returns @p true if the actor does NOT use groups, @p false otherwise.
77 bool GroupIdCheck(ulong param);
78
79 /**
80 * @brief Manages actor spawning when entering a level or area.
81 * @unofficial
82 * @param levelData The map actor data for the file/area.
83 * @param deleteVal A pointer to the delete value array for the file/area.
84 * @param spawnFlags A pointer to the spawn flags array for the file/area.
85 * @param mapActorCount The amount of map actors to process.
86 * @param isAreaReload Whether the area is being reloaded (e.g. next goto that points to the same area).
87 */
88 void MapActorInitialCreate(sMapActorData *levelData, u16 *deleteVal, u8 *spawnFlags, int mapActorCount, bool isAreaReload);
89
90 /// @brief Checks for screen scrolling and zoom changes to trigger spawning of nearby actors.
92
93 /// @brief Performs spawning of nearby actors as they enter the screen via scrolling or zoom changes.
94 /// @unofficial
95 /// @param createBounds The boundary data required to perform the screen-based checks.
96 /// @param isScreenScroll Whether the actor spawning is triggered by screen scrolling (1) or zoom changes (0).
97 void MapActorScrollCreate(sMapActorCreateBounds *createBounds, int isScreenScroll);
98
99 void incZposCount(); ///< Updates the Z-position index for the next spawned actor.
100 float addZposCount(); ///< Gets the Z position for the next spawned actor.
101 void incZposCount_layer2(); ///< Updates the Z-position index for the next spawned actor on layer 2.
102 float addZposCount_layer2(); ///< Gets the Z position for the next spawned actor on layer 2.
103 void incMapObjZposCount(); ///< Updates the Z-position index for the next spawned non-enemy actor.
104 float addMapObjZposCount(); ///< Gets the Z position for the next spawned non-enemy actor.
105 void incMapObjZposCount_layer2(); ///< Updates the Z-position index for the next spawned non-enemy actor on layer 2.
106 float addMapObjZposCount_layer2(); ///< Gets the Z position for the next spawned non-enemy actor on layer 2.
107
108 /**
109 * @brief Spawns an actor from the corresponding map actor data.
110 * @unofficial
111 * @param data The map actor data.
112 * @param info The map actor info.
113 * @param spawnFlags A pointer to the actor's spawn flags.
114 * @param deleteVal A pointer to the actor's delete value, or @p nullptr .
115 * @param areaNo The zone the actor will be linked to.
116 * @returns The spawned actor, or @p nullptr if it's a dummy actor or the actor creation fails.
117 */
118 dActor_c *mapActorSpawn(sMapActorData *data, dActorData_c *info, u8 *spawnFlags, u16 *deleteVal, u8 areaNo);
119
120 int mZPosCount; ///< The Z position index for the next spawned actor.
121 int mZPosCountLayer2; ///< The Z position index for the next spawned actor on layer 2.
122 int mMapObjZPosCount; ///< The Z position index for the next spawned non-enemy actor.
123 int mMapObjZPosCountLayer2; ///< The Z position index for the next spawned non-enemy actor on layer 2.
124
125 u16 mDeleteVals[MAX_MAP_ACTOR_COUNT]; ///< A value that each map actor can write to when it is deleted. @unused
126 u8 mSpawnFlags[MAX_MAP_ACTOR_COUNT]; ///< Flags indicating each map actor' spawn status. See dActor_c::ACTOR_SPAWN_FLAG_e.
127 u16 mYoshiColor; ///< The color of the next spawned Yoshi (egg).
128
129 bool mIsEndingDemo; ///< Whether an end-of-level cutscene is active.
130 bool mIsGoalPoleDemo; ///< Whether a goal flagpole cutscene is active.
131
132 int mScreenLeftPos; ///< The screen's left edge.
133 int mScreenTopPos; ///< The screen's top edge.
134 int mPrevScrollBoundaryTileX; ///< The previous scroll boundary on the X axis, used to check if the screen has scrolled.
135 int mPrevScrollBoundaryTileY; ///< The previous scroll boundary on the Y axis, used to check if the screen has scrolled.
136
137 static const ProfileName l_GoAheadEnemy[]; ///< The profiles allowed to spawn outside of the screen.
138 static dActorCreateMng_c *m_instance; ///< The static instance of the map actor creation manager.
139};
Manager for map actor creation.
int mScreenTopPos
The screen's top edge.
int mZPosCount
The Z position index for the next spawned actor.
void incZposCount()
Updates the Z-position index for the next spawned actor.
bool mIsEndingDemo
Whether an end-of-level cutscene is active.
int mMapObjZPosCount
The Z position index for the next spawned non-enemy actor.
dActor_c * mapActorSpawn(sMapActorData *data, dActorData_c *info, u8 *spawnFlags, u16 *deleteVal, u8 areaNo)
Spawns an actor from the corresponding map actor data.
int mPrevScrollBoundaryTileY
The previous scroll boundary on the Y axis, used to check if the screen has scrolled.
bool GroupIdCheck(ulong param)
Checks whether the provided actor parameters contain a group ID definition.
void incZposCount_layer2()
Updates the Z-position index for the next spawned actor on layer 2.
bool ScroolAreaInCheck(int boundsEdge, int areaEdge, int boundMin, int boundMax, int areaMin, int areaMax)
Checks whether an actor should be spawned based on the camera's current scroll position.
void incMapObjZposCount_layer2()
Updates the Z-position index for the next spawned non-enemy actor on layer 2.
void setMapActorCreate_next()
Initializes map actors on area reload.
bool GlobalActorCheck(sMapActorData *data)
Checks whether the profile associated to the map actor is allowed to ignore screen bounds on spawn.
static const ProfileName l_GoAheadEnemy[]
The profiles allowed to spawn outside of the screen.
void processGroupId(sMapActorData *data, u8 file, u32 mapActorIdx)
Adds a group-based map actor to the group manager.
float addMapObjZposCount_layer2()
Gets the Z position for the next spawned non-enemy actor on layer 2.
void incMapObjZposCount()
Updates the Z-position index for the next spawned non-enemy actor.
int mMapObjZPosCountLayer2
The Z position index for the next spawned non-enemy actor on layer 2.
int mScreenLeftPos
The screen's left edge.
u8 mSpawnFlags[MAX_MAP_ACTOR_COUNT]
Flags indicating each map actor' spawn status. See dActor_c::ACTOR_SPAWN_FLAG_e.
u16 mYoshiColor
The color of the next spawned Yoshi (egg).
void ActorCreateInfoClear()
Resets all temporary data for map actor spawning.
int mPrevScrollBoundaryTileX
The previous scroll boundary on the X axis, used to check if the screen has scrolled.
int mZPosCountLayer2
The Z position index for the next spawned actor on layer 2.
void MapActorScroolCreateCheck()
Checks for screen scrolling and zoom changes to trigger spawning of nearby actors.
bool mIsGoalPoleDemo
Whether a goal flagpole cutscene is active.
void MapActorInital_next()
Triggers actor creation on area reload.
float addMapObjZposCount()
Gets the Z position for the next spawned non-enemy actor.
bool ScroolAreaInLoopCheck(int boundsEdge, int areaEdge, int boundMin, int boundMax, int areaMin, int areaMax)
Checks whether an actor should be spawned due to being close to a screen edge (for looping stages).
float addZposCount()
Gets the Z position for the next spawned actor.
float addZposCount_layer2()
Gets the Z position for the next spawned actor on layer 2.
void MapActorInital_set()
Triggers actor creation on first area load.
u16 mDeleteVals[MAX_MAP_ACTOR_COUNT]
A value that each map actor can write to when it is deleted.
void MapActorInitialCreate(sMapActorData *levelData, u16 *deleteVal, u8 *spawnFlags, int mapActorCount, bool isAreaReload)
Manages actor spawning when entering a level or area.
void MapActorScrollCreate(sMapActorCreateBounds *createBounds, int isScreenScroll)
Performs spawning of nearby actors as they enter the screen via scrolling or zoom changes.
void setMapActorCreate()
Initializes map actors on first area load.
static dActorCreateMng_c * m_instance
The static instance of the map actor creation manager.
The configuration for a map actor.
The minimum required implementation for a stage actor.
Definition d_actor.hpp:15
#define MAX_MAP_ACTOR_COUNT
The maximum number of map actors that can exist simultaneously.
u16 ProfileName
The name of a profile. Value is a fProfile::PROFILE_NAME_e.
Definition f_profile.hpp:32