2#include <game/bases/d_actorcreate_manager.hpp>
3#include <game/bases/d_actor_group_manager.hpp>
4#include <game/bases/d_bg.hpp>
5#include <game/bases/d_info.hpp>
6#include <game/bases/d_s_stage.hpp>
7#include <game/bases/d_profile.hpp>
8#include <game/bases/d_bg_parameter.hpp>
12 fProfile::EN_PUKUCOIN,
14 fProfile::EN_BIGKARON,
15 fProfile::EN_KARON_HEAD,
16 fProfile::WAKI_KERONPA,
17 fProfile::PROFILE_NULL
31 if (boundsEdge == areaEdge) {
32 return boundMax >= areaMin && boundMin <= areaMax;
38 return ScroolAreaInCheck(boundsEdge, areaEdge, boundMin, boundMax, areaMin, areaMax);
79 dCdFile_c *file = dCd_c::m_instance->getFileP(dScStage_c::m_instance->mCurrFile);
90 dCdFile_c *file = dCd_c::m_instance->getFileP(dScStage_c::m_instance->mCurrFile);
91 u8 areaNo = dScStage_c::m_instance->getCurrArea();
118 dActorGroupIdMng_c::m_instance->process(data, GROUP_ID(data->mParam), file, mapActorIdx);
122 return GROUP_ID(param) == 0;
126 if (mapActorCount == 0 || levelData ==
nullptr) {
133 float screenPosX = bgParam->pos().x;
134 float screenPosY = bgParam->pos().y;
135 float screenWidth = bgParam->size().x;
136 float screenHeight = bgParam->size().y;
138 int screenLeft = screenPosX;
139 int screenTop = -(int) screenPosY;
141 int boundTop = screenTop - 32;
142 int boundBottom = screenTop + (int) screenHeight + 48;
143 int boundLeft = screenLeft - 48;
144 int boundRight = screenLeft + (int) screenWidth + 64;
146 int boundHalfHeight = (boundBottom - boundTop) >> 1;
147 int boundHalfWidth = (boundRight - boundLeft) >> 1;
148 int boundCenterY = boundTop + boundHalfHeight;
149 int boundCenterX = boundLeft + boundHalfWidth;
151 int actorCenterX, actorCenterY, actorHalfWidth, actorHalfHeight;
154 dCdFile_c *file = dCd_c::m_instance->getFileP(stage->mCurrFile);
155 u8 areaNo = dScStage_c::m_instance->getCurrArea();
157 while (i != mapActorCount) {
159 dActorData_c *mapActorInfo = dActorData_c::getMapActorInfo(levelData->mMapActorID);
161 bool globalActor =
false;
162 bool canSpawn =
false;
165 bool groupedActor =
false;
168 if (mapActorInfo->
mFlags & ACTOR_CREATE_GROUPABLE) {
186 if (file->getAreaNo(&bound) == areaNo) {
193 if (mapActorInfo->
mFlags & ACTOR_CREATE_GROUPABLE) {
202 bool spawnActor = globalActor;
203 if (!globalActor && canSpawn) {
204 if (mapActorInfo->
mFlags & ACTOR_CREATE_GLOBAL) {
214 abs(boundCenterX - actorCenterX) <= abs(boundHalfWidth + actorHalfWidth) &&
215 abs(boundCenterY - actorCenterY) <= abs(boundHalfHeight + actorHalfHeight)
223 mapActorSpawn(levelData, mapActorInfo, spawnFlags, deleteVal, areaNo);
245 sMapActorCreateBounds::BOUND_SCROLL_DIR_X_e scrollDirX = sMapActorCreateBounds::BOUND_SCROLL_X_LEFT;
246 sMapActorCreateBounds::BOUND_SCROLL_DIR_Y_e scrollDirY = sMapActorCreateBounds::BOUND_SCROLL_Y_UP;
248 float screenPosX = bgParam->pos().x;
249 float screenPosY = bgParam->pos().y;
250 float screenWidth = bgParam->size().x;
251 float screenHeight = bgParam->size().y;
253 int screenLeft = screenPosX;
254 int screenTop = -(int) screenPosY;
256 int tileLeft = (screenLeft - 32) >> 4;
257 int tileRight = (screenLeft + (int) screenWidth + 48) >> 4;
258 int tileTop = (screenTop - 16) >> 4;
259 int tileBottom = (screenTop + (int) screenHeight + 32) >> 4;
263 int scrollBoundaryTileX, scrollBoundaryTileY;
265 if (dBg_c::m_bg_p->getDispScale() != dBg_c::m_bg_p->getPrevDispScale()) {
266 createBounds.mScrollBoundaryTileX = tileLeft;
267 createBounds.mScrollBoundaryTileY = tileBottom;
268 createBounds.mTileLeft = tileLeft;
269 createBounds.mTileRight = tileRight;
270 createBounds.mTileTop = tileTop;
271 createBounds.mTileBottom = tileBottom;
272 createBounds.mScrollDirX = sMapActorCreateBounds::BOUND_SCROLL_X_LEFT;
273 createBounds.mScrollDirY = sMapActorCreateBounds::BOUND_SCROLL_Y_DOWN;
278 createBounds.mScrollBoundaryTileX = tileRight;
279 createBounds.mScrollBoundaryTileY = tileBottom;
280 createBounds.mTileLeft = tileLeft;
281 createBounds.mTileRight = tileRight;
282 createBounds.mTileTop = tileTop;
283 createBounds.mTileBottom = tileBottom;
284 createBounds.mScrollDirX = sMapActorCreateBounds::BOUND_SCROLL_X_RIGHT;
285 createBounds.mScrollDirY = sMapActorCreateBounds::BOUND_SCROLL_Y_DOWN;
290 scrollBoundaryTileX = tileRight;
291 scrollBoundaryTileY = tileTop;
293 createBounds.mScrollBoundaryTileX = tileRight;
294 createBounds.mScrollBoundaryTileY = tileTop;
295 createBounds.mScrollDirX = sMapActorCreateBounds::BOUND_SCROLL_X_RIGHT;
296 createBounds.mScrollDirY = sMapActorCreateBounds::BOUND_SCROLL_Y_UP;
302 if (bgScrollDirX != dBgParameter_c::BG_SCROLL_X_NONE) {
303 if (bgScrollDirX == dBgParameter_c::BG_SCROLL_X_RIGHT) {
305 scrollBoundaryTileX = tileRight;
306 scrollDirX = sMapActorCreateBounds::BOUND_SCROLL_X_RIGHT;
309 scrollBoundaryTileX = tileLeft;
314 scrollDirX = sMapActorCreateBounds::BOUND_SCROLL_X_NONE;
317 if (bgScrollDirY != dBgParameter_c::BG_SCROLL_Y_NONE) {
318 if (bgScrollDirY == (u32)dBgParameter_c::BG_SCROLL_Y_DOWN) {
320 scrollBoundaryTileY = tileBottom;
321 scrollDirY = sMapActorCreateBounds::BOUND_SCROLL_Y_DOWN;
324 scrollBoundaryTileY = tileTop;
329 scrollDirY = sMapActorCreateBounds::BOUND_SCROLL_Y_NONE;
334 createBounds.mScrollBoundaryTileX = scrollBoundaryTileX;
335 createBounds.mScrollBoundaryTileY = scrollBoundaryTileY;
336 createBounds.mTileLeft = tileLeft;
337 createBounds.mTileRight = tileRight;
338 createBounds.mTileTop = tileTop;
339 createBounds.mTileBottom = tileBottom;
340 createBounds.mScrollDirX = scrollDirX;
341 createBounds.mScrollDirY = scrollDirY;
354 u8 areaNo = stage->mCurrArea;
355 dCdFile_c *file = dCd_c::m_instance->getFileP(stage->mCurrFile);
358 if (mapActorCount == 0) {
363 if (data ==
nullptr) {
371 int actorCenterX, actorCenterY;
372 int scrollBoundaryTileX, actorTileLeft, actorTileRight;
373 int scrollBoundaryTileY, actorTileTop, actorTileBottom;
375 int createBoundaryTileX = createBounds->mScrollBoundaryTileX;
376 int createBoundaryTileY = createBounds->mScrollBoundaryTileY;
377 int boundsLeft = createBounds->mTileLeft;
378 int boundsRight = createBounds->mTileRight;
379 int boundsTop = createBounds->mTileTop;
380 int boundsBottom = createBounds->mTileBottom;
381 sMapActorCreateBounds::BOUND_SCROLL_DIR_X_e scrollDirX = createBounds->mScrollDirX;
382 sMapActorCreateBounds::BOUND_SCROLL_DIR_Y_e scrollDirY = createBounds->mScrollDirY;
384 for (u32 i = 0; i != mapActorCount; i++) {
386 dActorData_c *mapActorInfo = dActorData_c::getMapActorInfo(data->mMapActorID);
394 scrollBoundaryTileX = actorTileRight;
395 if (scrollDirX != sMapActorCreateBounds::BOUND_SCROLL_X_LEFT) {
396 scrollBoundaryTileX = actorTileLeft;
398 scrollBoundaryTileY = actorTileBottom;
399 if (scrollDirY != sMapActorCreateBounds::BOUND_SCROLL_Y_UP) {
400 scrollBoundaryTileY = actorTileTop;
403 bool groupedActor =
false;
404 if (mapActorInfo->
mFlags & ACTOR_CREATE_GROUPABLE) {
411 if (isScreenScroll) {
412 if (scrollBoundaryTileX == createBoundaryTileX) {
413 if (scrollDirX != sMapActorCreateBounds::BOUND_SCROLL_X_NONE) {
414 if (scrollDirX < 0) {
415 spawnActor =
ScroolAreaInCheck(boundsRight, actorTileLeft, boundsTop, boundsBottom, actorTileTop, actorTileBottom);
417 spawnActor =
ScroolAreaInCheck(boundsLeft, actorTileRight, boundsTop, boundsBottom, actorTileTop, actorTileBottom);
420 }
else if (scrollBoundaryTileY == createBoundaryTileY) {
421 if (scrollDirY != sMapActorCreateBounds::BOUND_SCROLL_Y_NONE) {
422 if (scrollDirY < 0) {
423 spawnActor =
ScroolAreaInLoopCheck(boundsBottom, actorTileTop, boundsLeft, boundsRight, actorTileLeft, actorTileRight);
425 spawnActor =
ScroolAreaInLoopCheck(boundsTop, actorTileBottom, boundsLeft, boundsRight, actorTileLeft, actorTileRight);
430 if (
ScroolAreaInCheck(createBoundaryTileX, scrollBoundaryTileX, boundsTop, boundsBottom, actorTileTop, actorTileBottom)) {
433 if (
ScroolAreaInCheck(createBoundaryTileY, scrollBoundaryTileY, boundsLeft, boundsRight, actorTileLeft, actorTileRight)) {
440 mapActorSpawn(data, mapActorInfo, spawnFlags, deleteVal, areaNo);
503 if (data->getProfileName() == fProfile::DUMMY_ACTOR) {
508 if (info->
mFlags & ACTOR_CREATE_MAPOBJ) {
509 if (data->mLayer != LAYER_1) {
515 if (data->mLayer != LAYER_1) {
538 if (actor !=
nullptr) {
539 if (data->mMapActorID >= 10) {
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.
int mSpawnRangeOffsetY
The vertical offset of the actor's bounding box from the actor's position.
u16 mSpawnMarginBottom
The additional padding added to the bottom of the bounding box to prevent pop-in.
int mSpawnRangeHalfWidth
The half-width of the actor's bounding box.
u16 mFlags
Various flags that control map actor spawning behaviour. Value is a bitfield from MAP_ACTOR_INFO_FLAG...
int mSpawnOffsetY
The vertical offset from the map actor to the actor's spawn position.
u16 mSpawnMarginTop
The additional padding added to the top of the bounding box to prevent pop-in.
u16 mSpawnMarginLeft
The additional padding added to the left of the bounding box to prevent pop-in.
int mSpawnRangeOffsetX
The horizontal offset of the actor's bounding box from the actor's position.
int mSpawnOffsetX
The horizontal offset from the map actor to the actor's spawn position.
u16 mSpawnMarginRight
The additional padding added to the right of the bounding box to prevent pop-in.
int mSpawnRangeHalfHeight
The half-height of the actor's bounding box.
The minimum required implementation for a stage actor.
static dActor_c * construct(ProfileName profName, unsigned long param, const mVec3_c *position, const mAng3_c *rotation, u8 layer)
Creates a stage actor without a parent.
static u8 m_flag_keep[2]
Temporary storage for the next created sprite actor's tracked event IDs. See mEventNums.
bool mBlockHit
Whether a block below the actor was hit.
static u64 m_flagbit_keep
Temporary storage for the next created sprite actor's event mask. See mEventMask.
u8 * mpSpawnFlags
The spawn flags for the actor. See ACTOR_SPAWN_FLAG_e.
mVec2_c mVisibleAreaSize
The size of the area inside which the actor is visible.
u8 mAreaNo
The actor's zone ID.
u8 mEventNums[2]
The event IDs the actor is tracking.
u64 mEventMask
The event mask, generated from mEventNums.
static u8 * m_read_p_keep
Temporary storage for the next created sprite actor's spawn flags. See mpSpawnFlags.
u16 mSpriteSpawnFlags
The spawn flags from the sprite data entry.
@ ACTOR_SPAWNED
The actor is spawned.
static u8 m_mbgchoice_keep
Temporary storage for the next created sprite actor's layer. See mLayer.
u8 mScrollDirY
See BG_SCROLL_DIR_Y_e.
u8 mScrollDirX
See BG_SCROLL_DIR_X_e.
Course data file holder. A course data file contains the actual course elements - areas,...
sMapActorData * mMapActorsByArea[MAX_AREAS]
Pointers to the first map actor for an area.
u32 mMapActorCountByArea[MAX_AREAS]
Number of map actors per area.
u32 mMapActorIdxForArea[MAX_AREAS]
Index of the first map actor for an area.
static unsigned int mGameFlag
See GAME_FLAG_e.
A three-dimensional floating point vector.
#define Z_POS_COUNT
The number of Z positions inside a layer.
#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.