Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
entity.c File Reference

Go to the source code of this file.

Macros

#define WORLD_ENTITY_HEAP_BOTTOM   0x80250000
 
#define WORLD_ENTITY_HEAP_BASE   0x80267FF0
 
#define entity_jan_iwa_VRAM   (void*) 0x802BAE00
 
#define entity_sbk_omo_VRAM   (void*) 0x802BAE00
 
#define entity_default_VRAM   (void*) 0x802BAE00
 

Functions

void update_shadows (void)
 
s32 step_entity_commandlist (Entity *entity)
 
void entity_swizzle_anim_pointers (EntityBlueprint *entityData, void *baseAnim, void *baseGfx)
 
void render_shadows (void)
 
void update_entity_transform_matrix (Entity *entity)
 
void update_shadow_transform_matrix (Shadow *shadow)
 
void update_entity_inverse_rotation_matrix (Entity *entity)
 
void delete_entity (s32 entityIndex)
 
void delete_entity_and_unload_data (s32 entityIndex)
 
void reload_world_entity_data (void)
 
s32 entity_get_collision_flags (Entity *entity)
 
void entity_free_static_data (EntityBlueprint *data)
 
s32 create_entity_shadow (Entity *entity, f32 x, f32 y, f32 z)
 
void update_entity_shadow_position (Entity *entity)
 
void update_entities (void)
 
void set_entity_commandlist (Entity *entity, s32 *entityScript)
 
void exec_entity_commandlist (Entity *entity)
 
void func_8010FD98 (void *arg0, s32 alpha)
 
void func_8010FE44 (void *arg0)
 
void entity_model_set_shadow_color (void *data)
 
void render_entities (void)
 
Entityget_entity_by_index (s32 index)
 
Shadowget_shadow_by_index (s32 index)
 
EntityListget_entity_list (void)
 
ShadowListget_shadow_list (void)
 
s32 entity_start_script (Entity *entity)
 
u32 get_entity_type (s32 index)
 
void delete_shadow (s32 shadowIndex)
 
s32 entity_try_partner_interaction_trigger (s32 entityIdx)
 
s32 test_player_entity_aabb (Entity *entity)
 
s32 is_player_action_state (s8 actionState)
 
void entity_set_render_script (Entity *entity, EntityModelScript *cmdList)
 
void entity_reset_collision (Entity *entity)
 
void load_area_specific_entity_data (void)
 
void clear_entity_data (b32 arg0)
 
void init_entity_data (void)
 
s32 is_entity_data_loaded (Entity *entity, EntityBlueprint *blueprint, s32 *loadedStart, s32 *loadedEnd)
 
void load_simple_entity_data (Entity *entity, EntityBlueprint *bp, s32 listIndex)
 
void load_split_entity_data (Entity *entity, EntityBlueprint *entityData, s32 listIndex)
 
s32 func_80111790 (EntityBlueprint *data)
 
s32 create_entity (EntityBlueprint *bp,...)
 
s32 create_shadow_from_data (ShadowBlueprint *bp, f32 x, f32 y, f32 z)
 
s32 create_shadow_type (s32 type, f32 x, f32 y, f32 z)
 
b32 entity_raycast_down (f32 *x, f32 *y, f32 *z, f32 *hitYaw, f32 *hitPitch, f32 *hitLength)
 Mostly used for shadows.
 
void set_standard_shadow_scale (Shadow *shadow, f32 height)
 
void set_npc_shadow_scale (Shadow *shadow, f32 height, f32 npcRadius)
 
void set_peach_shadow_scale (Shadow *shadow, f32 scale)
 
s32 is_block_on_ground (Entity *block)
 

Variables

s32 D_8014AFB0 = 255
 
s32 CreateEntityVarArgBuffer [4]
 
HiddenPanelsData gCurrentHiddenPanels
 
s32 gEntityHideMode
 
s32 D_801512BC
 
s32 D_80151304
 
s32 D_80151344
 
s32 entity_numEntities
 
s32 gEntityHeapBase
 
s32 gLastCreatedEntityIndex
 
s32 gEntityHeapBottom
 
s32 entity_numShadows
 
s32 isAreaSpecificEntityDataLoaded
 
s32 entity_updateCounter
 
BSS EntityList gWorldEntityList
 
BSS EntityList gBattleEntityList
 
BSS EntityListgCurrentEntityListPtr
 
BSS ShadowList gWorldShadowList
 
BSS ShadowList gBattleShadowList
 
BSS ShadowListgCurrentShadowListPtr
 
BSS s32 wEntityDataLoadedSize
 
BSS s32 bEntityDataLoadedSize
 
BSS EntityBlueprintwEntityBlueprint [MAX_ENTITIES+2]
 
BSS EntityBlueprintbEntityBlueprint [4]
 
BSS s32 D_801516FC
 
Addr BattleEntityHeapBottom
 

Macro Definition Documentation

◆ WORLD_ENTITY_HEAP_BOTTOM

#define WORLD_ENTITY_HEAP_BOTTOM   0x80250000

Definition at line 17 of file entity.c.

Referenced by clear_entity_data(), and init_entity_data().

◆ WORLD_ENTITY_HEAP_BASE

#define WORLD_ENTITY_HEAP_BASE   0x80267FF0

Definition at line 18 of file entity.c.

Referenced by clear_entity_data(), and init_entity_data().

◆ entity_jan_iwa_VRAM

#define entity_jan_iwa_VRAM   (void*) 0x802BAE00

Definition at line 19 of file entity.c.

◆ entity_sbk_omo_VRAM

#define entity_sbk_omo_VRAM   (void*) 0x802BAE00

Definition at line 20 of file entity.c.

◆ entity_default_VRAM

#define entity_default_VRAM   (void*) 0x802BAE00

Definition at line 21 of file entity.c.

Function Documentation

◆ update_shadows()

void update_shadows ( void )

Definition at line 203 of file entity.c.

203 {
204 s32 i;
205
207
208 for (i = 0; i < MAX_SHADOWS; i++) {
209 Shadow* shadow = get_shadow_by_index(i);
210
211 if (shadow != nullptr) {
213
214 if (!(shadow->flags & ENTITY_FLAG_SKIP_UPDATE)) {
217 }
218
220
223 } else {
225 }
226
228 delete_shadow(shadow->listIndex);
229 }
230 }
231 }
232 }
233}
BSS s32 PopupMenu_SelectedIndex
s16 entityModelID
Shadow * get_shadow_by_index(s32 index)
Definition entity.c:534
s32 entity_numShadows
Definition entity.c:47
void update_shadow_transform_matrix(Shadow *shadow)
Definition entity.c:496
void delete_shadow(s32 shadowIndex)
Definition entity.c:626
@ ENTITY_FLAG_HAS_ANIMATED_MODEL
Definition enums.h:2602
@ ENTITY_FLAG_SKIP_UPDATE
Definition enums.h:2629
@ ENTITY_FLAG_PENDING_INSTANCE_DELETE
Definition enums.h:2628
@ ENTITY_FLAG_ALWAYS_FACE_CAMERA
Definition enums.h:2612
void exec_entity_model_commandlist(s32 idx)
void update_model_animator(s32)
Definition animator.c:481
#define MAX_SHADOWS
Definition macros.h:92
Camera gCameras[4]
Definition cam_main.c:16
s32 gCurrentCameraID
Definition cam_math.c:5

Referenced by update_entities().

◆ step_entity_commandlist()

s32 step_entity_commandlist ( Entity * entity)

Definition at line 241 of file entity.c.

241 {
242 s32* args = entity->scriptReadPos;
243 s32 ret;
244 s32 labelId;
245 void (*tempfunc)(Entity*);
246
247 switch (*args++) {
249 entity->scriptDelay = -1;
250 entity->updateScriptCallback = nullptr;
251 entity->scriptReadPos = nullptr;
252 ret = false;
253 break;
255 entity->scriptReadPos = (s32*)*args;
256 entity->scriptDelay = 1;
257 entity->savedReadPos[0] = entity->scriptReadPos;
258 ret = true;
259 break;
261 tempfunc = (void (*)(Entity*))(*args++);
262 entity->scriptReadPos = args;
263 (tempfunc)(entity);
264 ret = true;
265 break;
267 entity->scriptDelay = *args++;
268 entity->updateScriptCallback = (s32 (*)(Entity*)) *args++;
269 entity->scriptReadPos = args++;
270 ret = false;
271 break;
273 entity->scriptReadPos = entity->savedReadPos[*args];
274 ret = true;
275 break;
277 labelId = *args++;
278 entity->savedReadPos[labelId] = args;
279 entity->scriptReadPos = args;
280 ret = true;
281 break;
283 if (entity->boundScriptBytecode != nullptr) {
285 }
286 entity->scriptReadPos = args++;
287 ret = true;
288 break;
290 entity->flags |= *args++;
291 entity->scriptReadPos = args++;
292 ret = true;
293 break;
295 entity->flags &= ~*args++;
296 entity->scriptReadPos = args++;
297 ret = true;
298 break;
300 sfx_play_sound(*args++);
301 entity->scriptReadPos = args++;
302 ret = true;
303 break;
304 default:
305 args++;
306 entity->scriptReadPos = args++;
307 ret = true;
308 break;
309 }
310 return ret;
311}
@ ENTITY_SCRIPT_OP_End
Definition entity.h:12
@ ENTITY_SCRIPT_OP_Label
Definition entity.h:17
@ ENTITY_SCRIPT_OP_Jump
Definition entity.h:13
@ ENTITY_SCRIPT_OP_PlaySound
Definition entity.h:21
@ ENTITY_SCRIPT_OP_RestartBoundScript
Definition entity.h:18
@ ENTITY_SCRIPT_OP_ClearFlags
Definition entity.h:20
@ ENTITY_SCRIPT_OP_Goto
Definition entity.h:16
@ ENTITY_SCRIPT_OP_SetFlags
Definition entity.h:19
@ ENTITY_SCRIPT_OP_Call
Definition entity.h:14
@ ENTITY_SCRIPT_OP_SetCallback
Definition entity.h:15
@ ENTITY_FLAG_BOUND_SCRIPT_DIRTY
Definition enums.h:2623
void sfx_play_sound(s32 soundID)

Referenced by exec_entity_commandlist(), and update_entities().

◆ entity_swizzle_anim_pointers()

void entity_swizzle_anim_pointers ( EntityBlueprint * entityData,
void * baseAnim,
void * baseGfx )

Definition at line 908 of file entity.c.

908 {
910 s32* ptr = (s32*)((s32)baseAnim + (s32)entityData->modelAnimationNodes);
911
912 while (true) {
913 if (*ptr == -1) {
914 *ptr = 0;
915 return;
916 }
917 node = (StaticAnimatorNode*)((s32)baseAnim + ((*ptr) & 0xFFFF));
918 *ptr++ = (s32)node;
919
920 if ((s32)node->displayList != -1) {
921 node->displayList = (Gfx*)((s32)baseGfx + ((s32)(node->displayList) & 0xFFFF));
922 } else {
923 node->displayList = nullptr;
924 }
925
926 if ((s32)node->sibling != -1) {
927 node->sibling = (StaticAnimatorNode*)((s32)baseAnim + ((s32)(node->sibling) & 0xFFFF));
928 } else {
929 node->sibling = nullptr;
930 }
931
932 if ((s32)node->child != -1) {
933 node->child = (StaticAnimatorNode*)((s32)baseAnim + ((s32)(node->child) & 0xFFFF));
934 } else {
935 node->child = nullptr;
936 }
937
938 if ((s32)node->vtxList != -1) {
939 node->vtxList = (Vtx*)((s32)baseGfx + ((s32)(node->vtxList) & 0xFFFFF));
940 } else {
941 node->vtxList = nullptr;
942 }
943 }
944}

Referenced by load_split_entity_data(), and reload_world_entity_data().

◆ render_shadows()

void render_shadows ( void )

Definition at line 424 of file entity.c.

424 {
425 s32 i;
426
427 for (i = 0; i < MAX_SHADOWS; i++) {
428 Shadow* shadow = get_shadow_by_index(i);
429
430 if (shadow != nullptr) {
431 if (shadow->flags & ENTITY_FLAG_HIDDEN) {
432 if (shadow->flags & ENTITY_FLAG_FADING_AWAY) {
433 shadow->alpha -= 20;
434 if (shadow->alpha <= 20) {
436 }
437 }
438 } else if (shadow->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL) {
439 if (shadow->vertexArray == nullptr) {
441 } else {
443 &shadow->transformMatrix,
444 shadow->vertexSegment,
445 shadow->vertexArray);
446 }
447 } else {
448 if (shadow->flags & ENTITY_FLAG_FADING_AWAY) {
449 shadow->alpha -= 20;
450 if (shadow->alpha <= 20) {
452 }
453 }
454
456
457 if (shadow->vertexArray == nullptr) {
459 } else {
461 &shadow->transformMatrix,
462 shadow->vertexSegment,
463 shadow->vertexArray);
464 }
465 }
466 }
467 }
468}
Mtx transformMatrix
Vec3s * vertexArray
s16 vertexSegment
void entity_model_set_shadow_color(void *data)
Definition entity.c:331
@ ENTITY_FLAG_HIDDEN
Definition enums.h:2599
@ ENTITY_FLAG_FADING_AWAY
Definition enums.h:2627
void draw_entity_model_A(s32, Mtx *)
void draw_entity_model_B(s32, Mtx *, s32, Vec3s *)
void bind_entity_model_setupGfx(s32 idx, void *setupGfxCallbackArg0, void(*fpSetupGfxCallback)(void *))
void render_animated_model_with_vertices(s32 animatorID, Mtx *rootTransform, s32 segment, void *baseAddr)
Definition animator.c:794
void render_animated_model(s32 animatorID, Mtx *rootTransform)
Definition animator.c:764

Referenced by render_entities().

◆ update_entity_transform_matrix()

void update_entity_transform_matrix ( Entity * entity)

Definition at line 470 of file entity.c.

470 {
478
479 if (entity->updateMatrixOverride != nullptr) {
480 entity->updateMatrixOverride(entity);
481 return;
482 }
483
484 guTranslateF(sp58, entity->pos.x, entity->pos.y, entity->pos.z);
485 guRotateF(spD8, entity->rot.x, 1.0f, 0.0f, 0.0f);
486 guRotateF(sp118, entity->rot.y, 0.0f, 1.0f, 0.0f);
487 guRotateF(sp158, entity->rot.z, 0.0f, 0.0f, 1.0f);
490 guScaleF(sp198, entity->scale.x, entity->scale.y, entity->scale.z);
493 guMtxF2L(sp98, &entity->transformMatrix);
494}
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF

Referenced by create_entity(), and update_entities().

◆ update_shadow_transform_matrix()

void update_shadow_transform_matrix ( Shadow * shadow)

Definition at line 496 of file entity.c.

496 {
504
505 guTranslateF(sp58, shadow->pos.x, shadow->pos.y, shadow->pos.z);
506 guRotateF(sp118, shadow->rot.x, 1.0f, 0.0f, 0.0f);
507 guRotateF(spD8, shadow->rot.y, 0.0f, 1.0f, 0.0f);
508 guRotateF(sp158, shadow->rot.z, 0.0f, 0.0f, 1.0f);
511 guScaleF(sp198, shadow->scale.x, shadow->scale.y, shadow->scale.z);
514 guMtxF2L(sp98, &shadow->transformMatrix);
515}
Vec3f scale

Referenced by create_shadow_from_data(), and update_shadows().

◆ update_entity_inverse_rotation_matrix()

void update_entity_inverse_rotation_matrix ( Entity * entity)

Definition at line 517 of file entity.c.

517 {
520
521 guRotateF(sp18, -entity->rot.y, 0.0f, 1.0f, 0.0f);
522 guRotateF(sp58, -entity->rot.z, 0.0f, 0.0f, 1.0f);
524 guRotateF(sp58, -entity->rot.x, 1.0f, 0.0f, 0.0f);
525 guMtxCatF(sp18, sp58, entity->inverseTransformMatrix);
526
527 entity->effectiveSize = sqrtf(((SQ(entity->aabb.x) + SQ(entity->aabb.z)) * 0.25f) + SQ(entity->aabb.y));
528}
#define sqrtf
#define SQ(x)
Definition macros.h:177

Referenced by update_entities().

◆ delete_entity()

void delete_entity ( s32 entityIndex)

Definition at line 578 of file entity.c.

578 {
580
581 if (entity->dataBuf.any != nullptr) {
582 heap_free(entity->dataBuf.any);
583 }
584
585 if (!(entity->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL)) {
586 free_entity_model_by_index(entity->virtualModelIndex);
587 } else {
589 }
590
591 if (entity->shadowIndex >= 0) {
592 Shadow* shadow = get_shadow_by_index(entity->shadowIndex);
593
595 }
596
598 (*gCurrentEntityListPtr)[entityIndex] = nullptr;
599}
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
BSS EntityList * gCurrentEntityListPtr
Definition entity.c:53
s32 heap_free(void *ptr)
Definition heap.c:42
void free_entity_model_by_index(s32 idx)
void delete_model_animator(ModelAnimator *animator)
Definition animator.c:297
ModelAnimator * get_animator_by_index(s32 animModelID)
Definition animator.c:1040

Referenced by update_entities().

◆ delete_entity_and_unload_data()

void delete_entity_and_unload_data ( s32 entityIndex)

Definition at line 601 of file entity.c.

601 {
603
604 if (entity->dataBuf.any != nullptr) {
605 heap_free(entity->dataBuf.any);
606 }
607
608 if (!(entity->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL)) {
609 free_entity_model_by_index(entity->virtualModelIndex);
610 } else {
612 }
613
615
616 if (entity->shadowIndex >= 0) {
617 Shadow* shadow = get_shadow_by_index(entity->shadowIndex);
618
620 }
621
623 (*gCurrentEntityListPtr)[entityIndex] = nullptr;
624}
void entity_free_static_data(EntityBlueprint *data)
Definition entity.c:1158

Referenced by update_entities().

◆ reload_world_entity_data()

void reload_world_entity_data ( void )

Definition at line 860 of file entity.c.

860 {
861 s32 i;
862 s32 totalSize = 0;
863 s32 temp1;
865 void* gfxData;
866 void* animData;
867
868 for (i = 0; i < MAX_ENTITIES; i++) {
870 if (bp == nullptr) {
871 break;
872 }
873
874 if (!(bp->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL)) {
875 void* gfxData;
876
877 dataLength = ((bp->dma.end - bp->dma.start) >> 2);
878 gfxData = (void*)(gEntityHeapBase - totalSize * 4 - dataLength * 4);
879 totalSize += dma_copy(bp->dma.start, bp->dma.end, gfxData) >> 2;
880 } else {
881 DmaEntry* dmaList = bp->dmaList;
882
883 if (bp->entityType == ENTITY_TYPE_RESET_MUNCHLESIA) {
884 gfxData = (void*)gEntityHeapBottom;
885 temp1 = dma_copy(dmaList[0].start, dmaList[0].end, gfxData) >> 2;
886 dma_copy(dmaList[1].start, dmaList[1].end, (void*)(gEntityHeapBottom + temp1 * 4)) >> 2;
887 animData = (void*)(gEntityHeapBottom + temp1 * 4);
889 } else {
890 s32 q;
891
892 dataLength = ((dmaList[0].end - dmaList[0].start) >> 2);
894 gfxData = (void*)(q - dataLength * 4);
895 totalSize += dma_copy(dmaList[0].start, dmaList[0].end, gfxData) >> 2;
896
897 dataLength = ((dmaList[1].end - dmaList[1].start) >> 2);
899 animData = (void*)(q - dataLength * 4);
900 totalSize += dma_copy(dmaList[1].start, dmaList[1].end, animData) >> 2;
901
903 }
904 }
905 }
906}
s32 gEntityHeapBottom
Definition entity.c:46
s32 gEntityHeapBase
Definition entity.c:43
void entity_swizzle_anim_pointers(EntityBlueprint *entityData, void *baseAnim, void *baseGfx)
Definition entity.c:908
BSS EntityBlueprint * wEntityBlueprint[MAX_ENTITIES+2]
Definition entity.c:61
@ ENTITY_TYPE_RESET_MUNCHLESIA
Definition enums.h:2587
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:442
#define MAX_ENTITIES
Definition macros.h:93

Referenced by init_entity_data().

◆ entity_get_collision_flags()

s32 entity_get_collision_flags ( Entity * entity)

Definition at line 634 of file entity.c.

634 {
635 u32 listIndex = entity->listIndex;
636 s32 entityFlags = 0;
637 u32 flag;
638
642 }
643
645 if (flag != -1 && (flag & COLLISION_WITH_ENTITY_BIT) && listIndex == (u8)flag) {
647 }
648
650 if (flag != -1 && (flag & COLLISION_WITH_ENTITY_BIT) && listIndex == (u8)flag) {
652 }
653
655 if (flag != -1 && (flag & COLLISION_WITH_ENTITY_BIT) && listIndex == (u8)flag) {
657 }
658
660 if (flag != -1 && (flag & COLLISION_WITH_ENTITY_BIT) && listIndex == (u8)flag) {
662 }
663
665 if (flag != -1 && (flag & COLLISION_WITH_ENTITY_BIT) && listIndex == (u8)flag) {
667 }
668
670 if (flag != -1 && (flag & COLLISION_WITH_ENTITY_BIT) && listIndex == (u8)flag && gPlayerStatusPtr->pressedButtons & BUTTON_A) {
672 }
673
674 return entityFlags;
675}
@ BUTTON_A
Definition enums.h:2776
@ ENTITY_COLLISION_PARTNER
Definition enums.h:2641
@ ENTITY_COLLISION_PLAYER_HAMMER
Definition enums.h:2640
@ ENTITY_COLLISION_PLAYER_TOUCH_WALL
Definition enums.h:2637
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2634
@ ENTITY_COLLISION_PLAYER_TOUCH_CEILING
Definition enums.h:2636
@ ENTITY_COLLISION_PLAYER_PUSHING_AGAINST
Definition enums.h:2638
@ ENTITY_COLLISION_PLAYER_LAST_FLOOR
Definition enums.h:2642
@ ENTITY_FLAG_PARTNER_COLLISION
Definition enums.h:2616
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:163
PlayerStatus * gPlayerStatusPtr
CollisionStatus gCollisionStatus
Definition 7BB60.c:5

Referenced by update_entities().

◆ entity_free_static_data()

void entity_free_static_data ( EntityBlueprint * data)

Definition at line 1158 of file entity.c.

1158 {
1159 s32 freeSlot;
1160 s32 size;
1162
1163 for (freeSlot = 0; freeSlot < MAX_ENTITIES; freeSlot++) {
1165 if (bp == nullptr) {
1166 break;
1167 }
1168 }
1169
1170 if (freeSlot < MAX_ENTITIES) {
1172 if (bp == data) {
1173 if (bp->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL) {
1174 DmaEntry* dmaList = bp->dmaList;
1175 size = ((dmaList[0].end - dmaList[0].start) >> 2);
1176 size += ((dmaList[1].end - dmaList[1].start) >> 2);
1177 if (!func_80111790(bp)) {
1178 wEntityBlueprint[freeSlot - 1] = nullptr;
1179 wEntityDataLoadedSize -= size;
1180 }
1181 } else {
1182 size = (bp->dma.end - bp->dma.start) >> 2;
1183 if (!func_80111790(bp)) {
1184 wEntityBlueprint[freeSlot - 1] = nullptr;
1185 wEntityDataLoadedSize -= size;
1186 }
1187 }
1188 }
1189 }
1190}
BSS s32 wEntityDataLoadedSize
Definition entity.c:58
s32 func_80111790(EntityBlueprint *data)
Definition entity.c:1143

Referenced by delete_entity_and_unload_data().

◆ create_entity_shadow()

s32 create_entity_shadow ( Entity * entity,
f32 x,
f32 y,
f32 z )

Definition at line 1506 of file entity.c.

1506 {
1507 u16 bpFlags = entity->blueprint->flags;
1508 s32 type;
1509 s16 shadowIndex;
1510
1513 } else {
1515 }
1516
1517 shadowIndex = create_shadow_type(type, x, y, z);
1518 entity->shadowIndex = shadowIndex;
1519
1521
1522 return entity->shadowIndex;
1523}
s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z)
Definition entity.c:1525
@ SHADOW_VARYING_CIRCLE
Definition enums.h:2521
@ SHADOW_FIXED_CIRCLE
Definition enums.h:2523
@ SHADOW_VARYING_SQUARE
Definition enums.h:2522
@ SHADOW_FIXED_SQUARE
Definition enums.h:2524
@ ENTITY_FLAG_DARK_SHADOW
Definition enums.h:2622
@ ENTITY_FLAG_SHADOW_POS_DIRTY
Definition enums.h:2621
@ ENTITY_FLAG_FIXED_SHADOW_SIZE
Definition enums.h:2608
@ ENTITY_FLAG_CIRCULAR_SHADOW
Definition enums.h:2610

Referenced by create_entity().

◆ update_entity_shadow_position()

void update_entity_shadow_position ( Entity * entity)

Definition at line 1557 of file entity.c.

1557 {
1558 Shadow* shadow = get_shadow_by_index(entity->shadowIndex);
1559
1560 if (shadow != nullptr) {
1561 f32 rayX;
1562 f32 rayY;
1563 f32 rayZ;
1564 f32 hitYaw;
1565 f32 hitPitch;
1566 f32 hitLength;
1568
1569 if (entity->alpha < 255) {
1570 shadow->alpha = entity->alpha / 2;
1571 } else {
1572 u8 alphaTemp;
1573
1574 if (shadow->flags & ENTITY_FLAG_DARK_SHADOW) {
1575 alphaTemp = 160;
1576 } else {
1577 alphaTemp = 128;
1578 }
1579 shadow->alpha = alphaTemp;
1580 }
1581
1582 if (!(entity->flags & ENTITY_FLAG_HAS_DYNAMIC_SHADOW)) {
1583 if (shadow->flags & ENTITY_FLAG_SHADOW_POS_DIRTY) {
1585 } else {
1586 return;
1587 }
1588 }
1589
1590 rayX = entity->pos.x;
1591 rayY = entity->pos.y;
1592 rayZ = entity->pos.z;
1593
1594 if (!entity_raycast_down(&rayX, &rayY, &rayZ, &hitYaw, &hitPitch, &hitLength) && hitLength == 32767.0f) {
1595 hitLength = 0.0f;
1596 }
1597
1599
1600 if (shadow->flags & ENTITY_FLAG_FIXED_SHADOW_SIZE) {
1601 hitLength = 212.5f;
1602 shadow->scale.x = entity->aabb.x / hitLength;
1603 shadow->scale.z = entity->aabb.z / hitLength;
1604 } else {
1605 hitLength = ((hitLength / 150.0f) + 0.95) * 250.0;
1606 shadow->scale.x = (entity->aabb.x / hitLength) * entity->scale.x;
1607 shadow->scale.z = (entity->aabb.z / hitLength) * entity->scale.z;
1608 }
1609
1610 shadow->pos.x = entity->pos.x;
1611 shadow->pos.z = entity->pos.z;
1612 shadow->pos.y = rayY;
1613 entity->shadowPosY = rayY;
1614 shadow->rot.x = hitYaw;
1615 shadow->rot.z = hitPitch;
1616 shadow->rot.y = entity->rot.y;
1617
1618 if (entity->pos.y < rayY) {
1619 shadow->flags |= ENTITY_FLAG_SKIP_UPDATE;
1620 entity->pos.y = rayY + 10.0f;
1621 } else {
1623 }
1624
1625 shadow->flags = (shadow->flags & ~ENTITY_FLAG_HIDDEN) | ((u16)entity->flags & ENTITY_FLAG_HIDDEN);
1626 if (!(entity->flags & ENTITY_FLAG_400) && origHitLength == 0.0f) {
1627 shadow->flags |= ENTITY_FLAG_HIDDEN;
1628 }
1629 } else {
1630 entity->shadowPosY = 0.0f;
1631 }
1632}
b32 entity_raycast_down(f32 *x, f32 *y, f32 *z, f32 *hitYaw, f32 *hitPitch, f32 *hitLength)
Mostly used for shadows.
Definition entity.c:1634
@ ENTITY_FLAG_400
Definition enums.h:2609
@ ENTITY_FLAG_HAS_DYNAMIC_SHADOW
Definition enums.h:2601

Referenced by update_entities().

◆ update_entities()

void update_entities ( void )

Definition at line 82 of file entity.c.

82 {
83 s32 i;
84
85 D_801512BC = 0;
88
89 for (i = 0; i < MAX_ENTITIES; i++) {
91
92 if (entity != nullptr) {
94
95 if (!(entity->flags & ENTITY_FLAG_SKIP_UPDATE)) {
98 if (!(entity->flags & ENTITY_FLAG_8000)) {
100 }
101 entity->boundScript = start_script(entity->boundScriptBytecode, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY);
102 }
103
104 if (entity->flags & ENTITY_FLAG_2000000) {
105 if (does_script_exist(entity->boundScript->id)) {
107 update_model_animator(entity->virtualModelIndex);
108 } else {
109 exec_entity_model_commandlist(entity->virtualModelIndex);
110 }
111
114 }
115
118 }
119 continue;
120 } else {
122 }
123 }
124
125 if (entity->collisionTimer == 0) {
126 entity->collisionFlags = entity_get_collision_flags(entity);
127
128 if (entity->collisionFlags) {
129 EntityCallback handleCollision = entity->blueprint->fpHandleCollision;
130
131 if (handleCollision != nullptr && handleCollision(entity) != 0) {
132 entity->collisionTimer = 10;
134 }
135 }
136 } else {
137 entity->collisionTimer--;
139 if (entity->collisionTimer == 0) {
141 } else {
143 }
144 } else if (entity->collisionTimer == 0) {
147 entity->collisionFlags = 0;
148 }
149 }
150
153 }
154
156 if (entity->updateScriptCallback != nullptr) {
157 entity->updateScriptCallback(entity);
158 }
159
160 if (entity->scriptReadPos != nullptr) {
161 if (entity->scriptDelay != 0) {
162 entity->scriptDelay--;
163 if (entity->scriptDelay == 0) {
165 }
166 }
167 }
168 }
169
172 }
173
174 if (!(entity->flags & ENTITY_FLAG_DISABLE_COLLISION)) {
176 }
177
179 update_model_animator(entity->virtualModelIndex);
180 } else {
181 exec_entity_model_commandlist(entity->virtualModelIndex);
182 }
183
184 if (entity->shadowIndex >= 0) {
186 }
187
189 delete_entity(entity->listIndex);
190 }
191
194 }
195 }
196 }
197 }
198
201}
s32(* EntityCallback)(struct Entity *)
void update_entity_shadow_position(Entity *entity)
Definition entity.c:1557
void update_shadows(void)
Definition entity.c:203
void delete_entity(s32 entityIndex)
Definition entity.c:578
void update_entity_transform_matrix(Entity *entity)
Definition entity.c:470
void update_entity_inverse_rotation_matrix(Entity *entity)
Definition entity.c:517
s32 step_entity_commandlist(Entity *entity)
Definition entity.c:241
s32 entity_get_collision_flags(Entity *entity)
Definition entity.c:634
void delete_entity_and_unload_data(s32 entityIndex)
Definition entity.c:601
s32 entity_updateCounter
Definition entity.c:49
s32 D_801512BC
Definition entity.c:39
HiddenPanelsData gCurrentHiddenPanels
Definition entity.c:36
s32 entity_numEntities
Definition entity.c:42
@ DEBUG_SCRIPTS_NONE
Definition enums.h:3874
@ ENTITY_FLAG_8000
Definition enums.h:2614
@ ENTITY_FLAG_DETECTED_COLLISION
Definition enums.h:2615
@ ENTITY_FLAG_CONTINUOUS_COLLISION
Definition enums.h:2605
@ ENTITY_FLAG_2000000
Definition enums.h:2624
@ ENTITY_FLAG_SKIP_UPDATE_TRANSFORM_MATRIX
Definition enums.h:2603
@ ENTITY_FLAG_DISABLE_COLLISION
Definition enums.h:2604
@ ENTITY_FLAG_PENDING_FULL_DELETE
Definition enums.h:2625
@ EVT_PRIORITY_A
Definition evt.h:154
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:162
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s32 does_script_exist(s32 id)
GameStatus * gGameStatusPtr
Definition main_loop.c:31

Referenced by step_game_loop().

◆ set_entity_commandlist()

void set_entity_commandlist ( Entity * entity,
s32 * entityScript )

Definition at line 235 of file entity.c.

235 {
236 entity->scriptReadPos = entityScript;
237 entity->scriptDelay = 1;
238 entity->savedReadPos[0] = entity->scriptReadPos;
239}

Referenced by entity_block_handle_collision(), entity_Chest_check_opened(), entity_ItemBlock_check_if_inactive(), entity_MulticoinBlock_spawn_coin(), and entity_SaveBlock_wait_for_close_choice().

◆ exec_entity_commandlist()

void exec_entity_commandlist ( Entity * entity)

Definition at line 313 of file entity.c.

313 {
315}

Referenced by action_update_use_spinning_flower(), entity_base_switch_animate_scale(), entity_BellbellPlant_idle(), entity_block_handle_collision(), entity_BlueWarpPipe_check_if_active(), entity_BlueWarpPipe_enter_pipe_update(), entity_BlueWarpPipe_idle(), entity_BlueWarpPipe_rise_up(), entity_BlueWarpPipe_wait_for_player_to_get_off(), entity_BlueWarpPipe_wait_player_move_to_center(), Entity_BoardedFloor_idle(), Entity_BoardedFloor_update_fragments(), entity_BombableRock_idle(), entity_BombableRock_update_fragments(), entity_Chest_idle(), entity_Chest_open(), entity_GiantChest_await_got_item(), entity_GiantChest_open(), entity_GreenStompSwitch_extend(), entity_GreenStompSwitch_idle(), entity_GreenStompSwitch_retract(), entity_HeartBlock_show_tutorial_message(), entity_HeartBlock_wait_for_close_tutorial(), entity_HeartBlockContent__anim_heal(), entity_HeartBlockContent_anim_idle(), entity_HiddenPanel_flip_over(), entity_HiddenPanel_idle(), entity_HugeBlueSwitch_idle(), entity_inactive_block_hit_anim(), entity_inactive_block_recoil_anim(), entity_ItemBlock_check_if_inactive(), entity_MulticoinBlock_idle(), entity_Padlock_idle(), entity_PinkFlower_idle(), entity_RedSwitch_animate_scale(), entity_RedSwitch_wait_and_reset(), entity_SaveBlock_show_tutorial_message(), entity_SaveBlock_wait_for_close_choice(), entity_SaveBlock_wait_for_close_result(), entity_SaveBlock_wait_for_close_tutorial(), entity_ScriptSpring_idle(), entity_shattering_idle(), entity_SimpleSpring_idle(), entity_small_switch_idle(), entity_StarBoxLauncher_check_launch(), entity_StarBoxLauncher_launch(), entity_TrumpetPlant_idle(), entity_WoodenCrate_idle(), entity_WoodenCrate_update_fragments(), func_802BB0A0_E2D9D0(), func_802BC050_E2E980(), and func_802BC99C_E312EC().

◆ func_8010FD98()

void func_8010FD98 ( void * arg0,
s32 alpha )

Definition at line 317 of file entity.c.

317 {
318 if (alpha >= 255) {
321 } else {
323 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
324 }
325}
#define PM_CC_01
Definition macros.h:287
#define PM_CC_02
Definition macros.h:288
Gfx * gMainGfxPos
Definition cam_main.c:14

Referenced by func_8010FE44().

◆ func_8010FE44()

void func_8010FE44 ( void * arg0)

Definition at line 327 of file entity.c.

327 {
329}
s32 D_8014AFB0
Definition entity.c:33
void func_8010FD98(void *arg0, s32 alpha)
Definition entity.c:317

Referenced by render_entities().

◆ entity_model_set_shadow_color()

void entity_model_set_shadow_color ( void * data)

Definition at line 331 of file entity.c.

331 {
332 s32 alpha = (s32)data;
333
335 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
336}
#define PM_CC1_SHADOW
Definition macros.h:446
#define PM_CC2_SHADOW
Definition macros.h:447

Referenced by render_shadows().

◆ render_entities()

void render_entities ( void )

Definition at line 338 of file entity.c.

338 {
339 s32 i;
340
341 for (i = 0; i < MAX_ENTITIES; i++) {
343
344 if (entity != nullptr) {
350 entity->pos.x,
351 entity->pos.z) > 200.0f
352 ) {
353 continue;
354 }
355
358 continue;
359 }
360 } else if (gEntityHideMode == ENTITY_HIDE_MODE_2) {
362 continue;
363 }
364 }
365 }
366
367 if (!(entity->flags & ENTITY_FLAG_HIDDEN)) {
369 if (D_8014AFB0 == 255) {
370 if (entity->renderSetupFunc != nullptr) {
372 entity->virtualModelIndex,
373 (void*)(u32) entity->listIndex,
374 (void (*)(void*)) entity->renderSetupFunc
375 );
376 }
377 } else {
379 entity->virtualModelIndex,
380 (void*)(u32) entity->listIndex,
382 );
383 }
384
385 if (entity->gfxBaseAddr == nullptr) {
386 render_animated_model(entity->virtualModelIndex, &entity->transformMatrix);
387 } else {
389 &entity->transformMatrix,
390 entity->vertexSegment,
391 entity->gfxBaseAddr);
392 }
393 } else {
394 if (D_8014AFB0 == 255) {
395 if (entity->renderSetupFunc != nullptr) {
397 entity->virtualModelIndex,
398 (void*)(u32) entity->listIndex,
399 (void (*)(void*)) entity->renderSetupFunc
400 );
401 } else {
402 get_entity_model(entity->virtualModelIndex)->fpSetupGfxCallback = nullptr;
403 }
404 } else {
405 bind_entity_model_setupGfx(entity->virtualModelIndex, (void*)(u32)entity->listIndex, func_8010FE44);
406 }
407
408 if (entity->gfxBaseAddr == nullptr) {
409 draw_entity_model_A(entity->virtualModelIndex, &entity->transformMatrix);
410 } else {
411 draw_entity_model_B(entity->virtualModelIndex,
412 &entity->transformMatrix,
413 entity->vertexSegment,
414 entity->gfxBaseAddr);
415 }
416 }
417 }
418 }
419 }
420
422}
s32 gEntityHideMode
Definition entity.c:37
void render_shadows(void)
Definition entity.c:424
void func_8010FE44(void *arg0)
Definition entity.c:327
EntityModel * get_entity_model(s32 idx)
@ ENTITY_HIDE_MODE_1
Definition enums.h:2647
@ ENTITY_HIDE_MODE_0
Definition enums.h:2646
@ ENTITY_HIDE_MODE_2
Definition enums.h:2648
@ CONTEXT_WORLD
Definition enums.h:3562
@ ENTITY_FLAG_IGNORE_DISTANCE_CULLING
Definition enums.h:2618
@ ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE2
Definition enums.h:2617
@ ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE1
Definition enums.h:2600
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
ModelAnimator * set_animator_render_callback(s32 animModelID, void *callbackArg, void(*callbackFunc)(void *))
Definition animator.c:1044
void(* fpSetupGfxCallback)(void *)
Definition entity.h:463

Referenced by render_frame().

◆ get_entity_by_index()

Entity * get_entity_by_index ( s32 index)

Definition at line 530 of file entity.c.

530 {
531 return (*gCurrentEntityListPtr)[index & 0xFFF];
532}

Referenced by action_hammer_end_swing(), action_update_landing_on_switch(), action_update_spin_jump(), action_update_tornado_jump(), action_update_use_spinning_flower(), check_for_interactables(), check_input_jump(), delete_entity(), delete_entity_and_unload_data(), entity_ArrowSign_setupGfx(), entity_base_block_setupGfx(), entity_BlueWarpPipe_setupGfx(), Entity_BoardedFloor_setupGfx(), entity_BombableRock_setupGfx(), entity_Chest_setupGfx(), entity_HeartBlock_create_child_entity(), entity_HeartBlockContent__reset(), entity_HeartBlockContent__setupGfx(), entity_HeartBlockContent_anim_idle(), entity_HeartBlockContent_set_initial_pos(), entity_HiddenPanel_setupGfx(), entity_HitItemBlock_show_inactive(), entity_ItemBlock_replace_with_inactive(), entity_ItemBlock_setupGfx(), entity_MulticoinBlock_spawn_coin(), entity_Padlock_setupGfx(), entity_PinkFlower_idle(), entity_PinkFlower_init(), entity_PinkFlowerLight_idle(), entity_PinkFlowerLight_setupGfx(), entity_SaveBlock_setupGfx(), entity_shattering_setupGfx(), entity_SpinningFlower_setupGfx(), entity_StarBoxLauncher_setupGfx(), entity_SuperBlockContent_attach_to_parent(), entity_SuperBlockContent_setupGfx(), entity_try_partner_interaction_trigger(), entity_Tweester_render_face(), entity_Tweester_render_inner_whirl(), entity_Tweester_render_outer_whirl(), entity_Tweester_setupGfx(), entity_upgrade_block_check_if_inactive(), entity_upgrade_block_hide_content(), entity_WoodenCrate_setupGfx(), func_802BC050_E2E980(), get_entity_type(), interact_inspect_update(), npc_find_standing_on_entity(), phys_player_land(), player_raycast_down(), player_raycast_general(), player_raycast_up_corner(), render_entities(), test_ray_entities(), and update_entities().

◆ get_shadow_by_index()

◆ get_entity_list()

EntityList * get_entity_list ( void )

Definition at line 538 of file entity.c.

538 {
540
543 } else {
545 }
546 return ret;
547}
Entity * EntityList[30]
BSS EntityList gBattleEntityList
Definition entity.c:52
BSS EntityList gWorldEntityList
Definition entity.c:51

Referenced by clear_entity_data(), and init_entity_data().

◆ get_shadow_list()

ShadowList * get_shadow_list ( void )

Definition at line 549 of file entity.c.

549 {
551
554 } else {
556 }
557 return ret;
558}
Shadow * ShadowList[60]
BSS ShadowList gBattleShadowList
Definition entity.c:55
BSS ShadowList gWorldShadowList
Definition entity.c:54

Referenced by clear_entity_data(), and init_entity_data().

◆ entity_start_script()

◆ get_entity_type()

◆ delete_shadow()

void delete_shadow ( s32 shadowIndex)

Definition at line 626 of file entity.c.

626 {
627 Shadow* shadow = get_shadow_by_index(shadowIndex);
628
630 heap_free((*gCurrentShadowListPtr)[shadowIndex]);
631 (*gCurrentShadowListPtr)[shadowIndex] = nullptr;
632}

Referenced by btl_delete_actor(), btl_delete_player_actor(), free_npc(), free_npc_by_index(), remove_item_entity_by_index(), remove_item_entity_by_reference(), remove_part_shadow(), and update_shadows().

◆ entity_try_partner_interaction_trigger()

s32 entity_try_partner_interaction_trigger ( s32 entityIdx)

Definition at line 677 of file entity.c.

677 {
678 s32 interacted = false;
679 u32 entityType = get_entity_type(entityIdx);
680 s32 partnerID = get_current_partner_id();
681 Entity* entity;
682
683 switch (partnerID) {
684 case PARTNER_BOMBETTE:
685 switch (entityType) {
686 default:
687 return false;
704 interacted = true;
705 }
706 break;
707 case PARTNER_KOOPER:
708 switch (entityType) {
709 default:
710 return false;
722 case ENTITY_TYPE_1C:
727 interacted = true;
728 }
729 break;
730 }
731 return interacted;
732}
u32 get_entity_type(s32 index)
Definition entity.c:568
@ ENTITY_TYPE_HAMMER1_BLOCK
Definition enums.h:2550
@ ENTITY_TYPE_SINGLE_TRIGGER_BLOCK
Definition enums.h:2545
@ ENTITY_TYPE_BOMBABLE_ROCK
Definition enums.h:2567
@ ENTITY_TYPE_HIDDEN_RED_BLOCK
Definition enums.h:2547
@ ENTITY_TYPE_1C
Definition enums.h:2557
@ ENTITY_TYPE_SUPER_BLOCK
Definition enums.h:2563
@ ENTITY_TYPE_HEALING_BLOCK
Definition enums.h:2556
@ ENTITY_TYPE_BLUE_SWITCH
Definition enums.h:2536
@ ENTITY_TYPE_MULTI_COIN_BRICK
Definition enums.h:2543
@ ENTITY_TYPE_RED_SWITCH
Definition enums.h:2537
@ ENTITY_TYPE_BRICK_BLOCK
Definition enums.h:2542
@ ENTITY_TYPE_HIDDEN_YELLOW_BLOCK
Definition enums.h:2546
@ ENTITY_TYPE_RED_BLOCK
Definition enums.h:2549
@ ENTITY_TYPE_SAVE_POINT
Definition enums.h:2561
@ ENTITY_TYPE_MULTI_TRIGGER_BLOCK
Definition enums.h:2540
@ ENTITY_TYPE_HAMMER1_BLOCK_TINY
Definition enums.h:2553
@ ENTITY_TYPE_YELLOW_BLOCK
Definition enums.h:2544
@ PARTNER_BOMBETTE
Definition enums.h:2922
@ PARTNER_KOOPER
Definition enums.h:2921
s8 get_current_partner_id(void)
Definition 7BB60.c:1101

Referenced by blast_affect_entities(), lateral_hit_interactable_entity(), and vertical_hit_interactable_entity().

◆ test_player_entity_aabb()

s32 test_player_entity_aabb ( Entity * entity)

Definition at line 734 of file entity.c.

734 {
738 f32 xDist;
739 f32 zDist;
740
741 if (yTemp > 0.0f || gPlayerStatus.colliderHeight + entity->aabb.y < fabsf(yTemp)) {
742 return 0;
743 }
744
746 xDist = fabsf(gPlayerStatus.pos.x - entity->pos.x);
747 zCollRadius = ((gPlayerStatus.colliderDiameter + entity->aabb.z) * 0.5);
748 zDist = fabsf(gPlayerStatus.pos.z - entity->pos.z);
749
750 if (xCollRadius < xDist || zCollRadius < zDist) {
751 return 0;
752 }
753
754 return 1;
755}
f32 fabsf(f32 f)
PlayerStatus gPlayerStatus
Definition 77480.c:38

◆ is_player_action_state()

s32 is_player_action_state ( s8 actionState)

Definition at line 757 of file entity.c.

757 {
758 return actionState == gPlayerStatus.actionState;
759}

◆ entity_set_render_script()

void entity_set_render_script ( Entity * entity,
EntityModelScript * cmdList )

Definition at line 761 of file entity.c.

761 {
762 if (!(entity->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL)) {
763 set_entity_model_render_command_list(entity->virtualModelIndex, cmdList);
764 }
765}
void set_entity_model_render_command_list(s32 idx, EntityModelScript *cmdList)

Referenced by Entity_BoardedFloor_shatter(), entity_HeartBlock_change_render_script(), entity_HeartBlockContent__anim_heal(), entity_HeartBlockContent_reset(), entity_HiddenPanel_init(), and entity_WoodenCrate_idle().

◆ entity_reset_collision()

void entity_reset_collision ( Entity * entity)

Definition at line 767 of file entity.c.

767 {
768 entity->collisionTimer = 0;
770}

◆ load_area_specific_entity_data()

void load_area_specific_entity_data ( void )

Definition at line 772 of file entity.c.

772 {
773 //TODO hardcoded map and area IDs, connect these to MapTable.xml eventually
779 } else {
781 }
782
784 }
785}
s32 isAreaSpecificEntityDataLoaded
Definition entity.c:48
@ AREA_SBK
Definition enums.h:3004
@ AREA_OMO
Definition enums.h:3010
@ AREA_JAN
Definition enums.h:3011
@ AREA_IWA
Definition enums.h:3002
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:537

Referenced by create_entity().

◆ clear_entity_data()

void clear_entity_data ( b32 arg0)

Definition at line 787 of file entity.c.

787 {
788 s32 i;
789
790 D_801516FC = 1;
794 D_80151304 = 0;
795
798 }
799
803 if (!arg0) {
804 D_80151344 = 0;
805 }
806 D_8014AFB0 = 255;
807
810 for (i = 0; i < MAX_ENTITIES; i++) {
811 wEntityBlueprint[i] = nullptr;
812 }
813 } else {
815 for (i = 0; i < ARRAY_COUNT(bEntityBlueprint); i++) {
816 bEntityBlueprint[i] = nullptr;
817 }
818 }
819
823 } else {
826 }
827
830
831 for (i = 0; i < MAX_ENTITIES; i++) {
832 (*gCurrentEntityListPtr)[i] = nullptr;
833 }
834
835 for (i = 0; i < MAX_SHADOWS; i++) {
836 (*gCurrentShadowListPtr)[i] = nullptr;
837 }
838}
EntityList * get_entity_list(void)
Definition entity.c:538
BSS s32 bEntityDataLoadedSize
Definition entity.c:59
#define WORLD_ENTITY_HEAP_BOTTOM
Definition entity.c:17
BSS EntityBlueprint * bEntityBlueprint[4]
Definition entity.c:62
s32 D_80151304
Definition entity.c:40
#define WORLD_ENTITY_HEAP_BASE
Definition entity.c:18
s32 D_80151344
Definition entity.c:41
BSS s32 D_801516FC
Definition entity.c:63
Addr BattleEntityHeapBottom
ShadowList * get_shadow_list(void)
Definition entity.c:549
#define ARRAY_COUNT(arr)
Definition macros.h:39

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), state_step_startup(), and state_step_title_screen().

◆ init_entity_data()

void init_entity_data ( void )

Definition at line 840 of file entity.c.

Referenced by state_step_end_battle(), and state_step_unpause().

◆ is_entity_data_loaded()

s32 is_entity_data_loaded ( Entity * entity,
EntityBlueprint * blueprint,
s32 * loadedStart,
s32 * loadedEnd )

Definition at line 946 of file entity.c.

946 {
948 s32 i;
949 s32 ret;
951
952 *loadedStart = 0;
953 *loadedEnd = 0;
954 ret = false;
955
958 } else {
960 }
961
962 for (i = 0; i < MAX_ENTITIES; i++, blueprints++) {
964 if (bp == nullptr) {
965 blueprints[0] = blueprint;
966 blueprints[1] = nullptr;
967 ret = true;
968 if (blueprint->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL) {
969 s32 size;
970 entDmaList = blueprint->dmaList;
971 size = (entDmaList[0].end - entDmaList[0].start) >> 2;
972 *loadedEnd = *loadedStart + size;
973 }
974 break;
975 } else {
976 DmaEntry* bpDmaList = bp->dmaList;
977 entDmaList = blueprint->dmaList;
978 if (bpDmaList == entDmaList) {
979 if (blueprint->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL) {
980 s32 size = (bpDmaList[0].end - bpDmaList[0].start) >> 2;
981 *loadedEnd = *loadedStart + size;
982 }
983 break;
984 } else if (bp == blueprint) {
985 if (bp->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL) {
986 s32 size = (entDmaList[0].end - entDmaList[0].start) >> 2;
987 *loadedEnd = *loadedStart + size;
988 }
989 break;
990 } else {
991 if (bp->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL) {
992 s32 size = (bpDmaList[0].end - bpDmaList[0].start) >> 2;
993 *loadedEnd = *loadedStart = *loadedStart + size;
994 size = (bpDmaList[1].end - bpDmaList[1].start) >> 2;
995 *loadedStart = *loadedStart + size;
996 } else {
997 *loadedStart += (bp->dma.end - bp->dma.start) >> 2;
998 }
999 }
1000 }
1001 }
1002
1003 return ret;
1004}

Referenced by load_simple_entity_data(), and load_split_entity_data().

◆ load_simple_entity_data()

void load_simple_entity_data ( Entity * entity,
EntityBlueprint * bp,
s32 listIndex )

Definition at line 1006 of file entity.c.

1006 {
1008 s32 loadedEnd;
1010 s32 totalSize;
1011
1012 entity->vertexSegment = 0xA;
1015 } else {
1017 }
1018
1020 if (totalSize + ((bp->dma.end - bp->dma.start) >> 2) > 0x5FFCU) {
1021 get_entity_type(entity->listIndex);
1022 get_entity_type(entity->listIndex);
1023 PANIC();
1024 }
1025 entitySize = (bp->dma.end - bp->dma.start) >> 2;
1026 entity->gfxBaseAddr = (void*)(gEntityHeapBase - totalSize * 4 - entitySize * 4);
1027 totalSize += dma_copy(bp->dma.start, bp->dma.end, entity->gfxBaseAddr) >> 2;
1028 get_entity_type(entity->listIndex);
1029 } else {
1030 entitySize = (bp->dma.end - bp->dma.start) >> 2;
1031 entity->gfxBaseAddr = (void*)(gEntityHeapBase - loadedStart * 4 - entitySize * 4);
1032 get_entity_type(entity->listIndex);
1033 }
1034
1037 } else {
1039 }
1040}
s32 is_entity_data_loaded(Entity *entity, EntityBlueprint *blueprint, s32 *loadedStart, s32 *loadedEnd)
Definition entity.c:946
#define PANIC()
Definition macros.h:54

Referenced by create_entity().

◆ load_split_entity_data()

void load_split_entity_data ( Entity * entity,
EntityBlueprint * entityData,
s32 listIndex )

Definition at line 1042 of file entity.c.

1042 {
1043 s32 swizzlePointers = false;
1045 void* animBaseAddr;
1049 s32 dma1size;
1053
1055 DmaEntry* dmaList = entityData->dmaList;
1056 entity->vertexSegment = 0xA;
1057
1058 switch (entityData->entityType) {
1063 specialSize = 0x1000;
1064 break;
1069 specialSize = 0x2BC0;
1070 break;
1071 default:
1072 specialSize = 0;
1073 break;
1074 }
1075
1076 if (specialSize != 0) {
1077 if (entityData->entityType == ENTITY_TYPE_RESET_MUNCHLESIA) {
1079 }
1080 specialSize -= 0x1000;
1081
1082 dma1size = dma_copy(dmaList[0].start, dmaList[0].end, (void*)(gEntityHeapBottom + specialSize * 4)) / 4;
1083 entity->gfxBaseAddr = (void*)(gEntityHeapBottom + specialSize * 4);
1084 dma_copy(dmaList[1].start, dmaList[1].end, (void*)(gEntityHeapBottom + specialSize * 4 + dma1size * 4));
1085 animBaseAddr = (void*)(gEntityHeapBottom + specialSize * 4 + dma1size * 4);
1086 swizzlePointers = true;
1090 } else {
1092 }
1093
1094 if ((totalLoaded + ((dmaList[0].end - dmaList[0].start) >> 2)) > 0x5FFCU) {
1095 get_entity_type(entity->listIndex);
1096 PANIC();
1097 }
1098
1099 if ((totalLoaded + ((dmaList[1].end - dmaList[1].start) >> 2)) > 0x5FFCU) {
1100 get_entity_type(entity->listIndex);
1101 PANIC();
1102 }
1103
1104 dma2size_1 = dma_copy(dmaList[0].start, dmaList[0].end, dmaList[0].start + ((gEntityHeapBase - totalLoaded * 4 - (s32)dmaList[0].end) >> 2) * 4) >> 2;
1105 entity->gfxBaseAddr = (void*)(gEntityHeapBase - totalLoaded * 4 - dma2size_1 * 4);
1107
1108 dma2size_2 = dma_copy(dmaList[1].start, dmaList[1].end, dmaList[1].start + ((gEntityHeapBase - totalLoaded * 4 - (s32)dmaList[1].end) >> 2) * 4) >> 2;
1109 animBaseAddr = (void*)(gEntityHeapBase - totalLoaded * 4 - dma2size_2 * 4);
1111 get_entity_type(entity->listIndex);
1112
1115 } else {
1117 }
1118 swizzlePointers = true;
1119 } else {
1120 u32 temp = (dmaList[0].end - dmaList[0].start) >> 2;
1121 entity->gfxBaseAddr = (void*)(gEntityHeapBase - loadedStart * 4 - temp * 4);
1122 temp = (dmaList[1].end - dmaList[1].start) >> 2;
1123 animBaseAddr = (void*)(gEntityHeapBase - loadedEnd * 4 - temp * 4);
1124 get_entity_type(entity->listIndex);
1125 }
1126 } else {
1127 entity->virtualModelIndex = create_model_animator(entityData->renderCommandList);
1128 load_model_animator_tree(entity->virtualModelIndex, entityData->modelAnimationNodes);
1129 update_model_animator(entity->virtualModelIndex);
1130 return;
1131 }
1132 animationScript = entityData->renderCommandList;
1133 animationNodes = (StaticAnimatorNode**)((s32)animBaseAddr + (s32)entityData->modelAnimationNodes);
1134 if (swizzlePointers) {
1136 }
1138 load_mesh_animator_tree(entity->virtualModelIndex, animationNodes);
1139 update_model_animator(entity->virtualModelIndex);
1141}
@ ENTITY_TYPE_MUNCHLESIA_ENVELOP
Definition enums.h:2589
@ ENTITY_TYPE_MUNCHLESIA_CHEWING
Definition enums.h:2591
@ ENTITY_TYPE_MUNCHLESIA_BEGIN_CHEW
Definition enums.h:2590
@ ENTITY_TYPE_MUNCHLESIA_RESET2
Definition enums.h:2594
@ ENTITY_TYPE_MUNCHLESIA_GRAB
Definition enums.h:2588
@ ENTITY_TYPE_MUNCHLESIA_SPIT_OUT
Definition enums.h:2592
@ ENTITY_TYPE_MUNCHLESIA_RESET1
Definition enums.h:2593
void load_mesh_animator_tree(s32 index, StaticAnimatorNode **tree)
Definition animator.c:1197
s32 create_model_animator(s16 *animPos)
Definition animator.c:318
s32 create_mesh_animator(s16 *animPos, s16 *animBuffer)
Definition animator.c:366
void load_model_animator_tree(s32, StaticAnimatorNode **)
Definition animator.c:1170

Referenced by create_entity().

◆ func_80111790()

s32 func_80111790 ( EntityBlueprint * data)

Definition at line 1143 of file entity.c.

1143 {
1144 s32 i;
1145
1146 for (i = 0; i < ARRAY_COUNT(*gCurrentEntityListPtr); i++) {
1147 Entity* entity = (*gCurrentEntityListPtr)[i];
1148
1149 if (entity != nullptr && entity->blueprint->dma.start != nullptr) {
1150 if (entity->blueprint->dma.start == entity->blueprint) {
1151 return true;
1152 }
1153 }
1154 }
1155 return false;
1156}

Referenced by entity_free_static_data().

◆ create_entity()

s32 create_entity ( EntityBlueprint * bp,
... )

Definition at line 1192 of file entity.c.

1192 {
1193 va_list ap;
1194 f32 x, y, z;
1195 f32 rotY;
1196 s32 listIndex;
1197 Entity* entity;
1198 s32 idx;
1199
1200 va_start(ap, bp);
1201
1203
1204 x = va_arg(ap, s32);
1205 y = va_arg(ap, s32);
1206 z = va_arg(ap, s32);
1207 rotY = va_arg(ap, s32);
1208
1211 }
1212
1214 s32 arg = va_arg(ap, s32);
1215
1216 if (arg == MAKE_ENTITY_END) {
1217 break;
1218 }
1220 }
1221
1222 va_end(ap);
1223
1224 for (listIndex = 0; listIndex < ARRAY_COUNT(*gCurrentEntityListPtr); listIndex++) {
1225 if ((*gCurrentEntityListPtr)[listIndex] == nullptr) {
1226 break;
1227 }
1228 }
1229
1230 if (listIndex >= MAX_ENTITIES) {
1231 return -1;
1232 }
1233
1234 (*gCurrentEntityListPtr)[listIndex] = entity = heap_malloc(sizeof(*entity));
1235 mem_clear(entity, sizeof(*entity));
1236 entity->dataBuf.any = nullptr;
1237 if (bp->typeDataSize != 0) {
1238 entity->dataBuf.any = heap_malloc(bp->typeDataSize);
1239 mem_clear(entity->dataBuf.any, bp->typeDataSize);
1240 }
1241 entity->type = bp->entityType;
1242 entity->listIndex = listIndex;
1243 entity->boundScript = nullptr;
1244 entity->updateMatrixOverride = nullptr;
1245 entity->blueprint = bp;
1246 entity->scriptReadPos = bp->updateEntityScript;
1247 entity->scriptDelay = entity->scriptReadPos != nullptr ? 1 : 0;
1248 entity->savedReadPos[0] = bp->updateEntityScript;
1249 entity->updateScriptCallback = nullptr;
1250 entity->flags = bp->flags | ENTITY_FLAG_CREATED;
1251 entity->collisionFlags = 0;
1252 entity->collisionTimer = 0;
1253 entity->renderSetupFunc = nullptr;
1254 entity->pos.x = x;
1255 entity->pos.y = y;
1256 entity->pos.z = z;
1257 entity->rot.x = 0.0f;
1258 entity->rot.y = rotY;
1259 entity->rot.z = 0.0f;
1260 entity->scale.x = 1.0f;
1261 entity->scale.y = 1.0f;
1262 entity->scale.z = 1.0f;
1263 entity->aabb.x = bp->aabbSize[0];
1264 entity->aabb.y = bp->aabbSize[1];
1265 entity->aabb.z = bp->aabbSize[2];
1266 entity->unk_05 = 1;
1267 entity->unk_08 = -1;
1268 entity->alpha = 255;
1269 entity->virtualModelIndex = -1;
1270 entity->shadowIndex = -1;
1271 entity->gfxBaseAddr = nullptr;
1272
1273 if (!(bp->flags & ENTITY_FLAG_HAS_ANIMATED_MODEL)) {
1274 if (bp->dma.start != 0) {
1275 load_simple_entity_data(entity, bp, listIndex);
1276 }
1277 if (bp->renderCommandList != nullptr) {
1278 entity->virtualModelIndex = load_entity_model(bp->renderCommandList);
1279 exec_entity_model_commandlist(entity->virtualModelIndex);
1280 }
1281 } else {
1282 load_split_entity_data(entity, bp, listIndex);
1283 }
1284
1286 create_entity_shadow(entity, x, y, z);
1287 }
1288
1289 switch (bp->entityType) {
1295 entity->flags |= ENTITY_FLAG_4000;
1296 break;
1297 }
1298
1299 if (bp->fpInit != nullptr) {
1300 bp->fpInit(entity);
1301 }
1302
1304 return entity->listIndex;
1305}
#define mem_clear
s32 create_entity_shadow(Entity *entity, f32 x, f32 y, f32 z)
Definition entity.c:1506
void load_simple_entity_data(Entity *entity, EntityBlueprint *bp, s32 listIndex)
Definition entity.c:1006
void load_area_specific_entity_data(void)
Definition entity.c:772
s32 CreateEntityVarArgBuffer[4]
Definition entity.c:35
void load_split_entity_data(Entity *entity, EntityBlueprint *entityData, s32 listIndex)
Definition entity.c:1042
s32 load_entity_model(EntityModelScript *cmdList)
@ ENTITY_TYPE_SCRIPT_SPRING
Definition enums.h:2570
@ ENTITY_TYPE_SIMPLE_SPRING
Definition enums.h:2569
@ ENTITY_TYPE_STAR_BOX_LAUNCHER
Definition enums.h:2572
@ ENTITY_TYPE_SHADOW
Definition enums.h:2530
@ ENTITY_FLAG_HAS_SHADOW
Definition enums.h:2607
@ ENTITY_FLAG_CREATED
Definition enums.h:2630
@ ENTITY_FLAG_4000
Definition enums.h:2613
#define MAKE_ENTITY_END
Definition evt.h:108
void * heap_malloc(s32 size)
Definition heap.c:34

Referenced by entity_breakable_block_create_shattering_entity(), entity_HeartBlock_create_child_entity(), entity_ItemBlock_check_if_inactive(), entity_ItemBlock_replace_with_inactive(), entity_MulticoinBlock_check_if_inactive(), entity_MulticoinBlock_idle(), entity_MulticoinBlock_spawn_coin(), entity_Munchlesia_create_child(), entity_PinkFlower_init(), and entity_upgrade_block_check_if_inactive().

◆ create_shadow_from_data()

s32 create_shadow_from_data ( ShadowBlueprint * bp,
f32 x,
f32 y,
f32 z )

Definition at line 1307 of file entity.c.

1307 {
1308 Shadow* shadow;
1309 s32 i;
1310
1311 for (i = 0; i < ARRAY_COUNT(*gCurrentShadowListPtr); i++) {
1312 if ((*gCurrentShadowListPtr)[i] == nullptr) {
1313 break;
1314 }
1315 }
1316
1318
1319 shadow = heap_malloc(sizeof(*shadow));
1320 (*gCurrentShadowListPtr)[i] = shadow;
1321 mem_clear(shadow, sizeof(*shadow));
1322 shadow->listIndex = i;
1323 shadow->flags = bp->flags | ENTITY_FLAG_CREATED;
1324 shadow->alpha = 128;
1325 shadow->unk_06 = 0x80;
1326 shadow->pos.x = x;
1327 shadow->pos.y = y;
1328 shadow->pos.z = z;
1329 shadow->scale.x = 1.0f;
1330 shadow->scale.y = 1.0f;
1331 shadow->scale.z = 1.0f;
1332
1333 if (bp->animModelNode != nullptr) {
1335 shadow->entityModelID = create_model_animator(bp->renderCommandList);
1336 load_model_animator_tree(shadow->entityModelID, bp->animModelNode);
1337 } else {
1338 shadow->entityModelID = load_entity_model(bp->renderCommandList);
1339 }
1340
1341 if (bp->onCreateCallback != nullptr) {
1342 bp->onCreateCallback(shadow);
1343 }
1345 return shadow->listIndex;
1346}
#define ASSERT(condition)

Referenced by create_shadow_type().

◆ create_shadow_type()

s32 create_shadow_type ( s32 type,
f32 x,
f32 y,
f32 z )

Definition at line 1525 of file entity.c.

1525 {
1526 s32 isFixedSize = false;
1528 s32 shadowIndex;
1529
1530 switch (type) {
1532 isFixedSize = true;
1535 break;
1537 isFixedSize = true;
1539 bp = &SquareShadow;
1540 break;
1542 isFixedSize = true;
1545 break;
1546 }
1547
1548 shadowIndex = create_shadow_from_data(bp, x, y, z);
1549
1550 if (isFixedSize) {
1552 }
1553
1554 return shadowIndex;
1555}
s32 create_shadow_from_data(ShadowBlueprint *bp, f32 x, f32 y, f32 z)
Definition entity.c:1307
ShadowBlueprint SquareShadow
Definition Shadow.c:124
ShadowBlueprint CircularShadowB
Definition Shadow.c:115
ShadowBlueprint CircularShadowA
Definition Shadow.c:106
@ SHADOW_FIXED_ALT_CIRCLE
Definition enums.h:2526
@ SHADOW_VARYING_ALT_CIRCLE
Definition enums.h:2525

Referenced by create_actor(), create_entity_shadow(), create_npc_impl(), create_part_shadow(), create_part_shadow_by_ref(), load_partner_actor(), load_player_actor(), make_item_entity(), make_item_entity_at_player(), and player_reset_data().

◆ entity_raycast_down()

b32 entity_raycast_down ( f32 * x,
f32 * y,
f32 * z,
f32 * hitYaw,
f32 * hitPitch,
f32 * hitLength )

Mostly used for shadows.

Definition at line 1634 of file entity.c.

1634 {
1635 f32 hitX, hitY, hitZ;
1636 f32 hitDepth;
1637 f32 hitNx, hitNy, hitNz;
1638 s32 entityID;
1639 s32 colliderID;
1640 s32 hitID;
1641
1642 hitDepth = 32767.0f;
1643 hitID = NO_COLLIDER;
1644
1645 entityID = test_ray_entities(*x, *y, *z, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);
1646
1647 if ((entityID > NO_COLLIDER) && ((get_entity_type(entityID) != ENTITY_TYPE_PUSH_BLOCK) || (hitNx == 0.0f && hitNz == 0.0f && hitNy == 1.0))) {
1649 }
1650
1651 colliderID = test_ray_colliders(COLLIDER_FLAG_IGNORE_PLAYER, *x, *y, *z, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &hitNx,
1652 &hitNy, &hitNz);
1653 if (colliderID > NO_COLLIDER) {
1654 hitID = colliderID;
1655 }
1656
1657 if (hitID > NO_COLLIDER) {
1658 *y = hitY;
1660 *hitYaw = -atan2(0.0f, 0.0f, hitNz * 100.0f, hitNy * 100.0f);
1661 *hitPitch = -atan2(0.0f, 0.0f, hitNx * 100.0f, hitNy * 100.0f);
1662 return true;
1663 } else {
1664 *hitLength = 32767.0f;
1665 *hitYaw = 0.0f;
1666 *hitPitch = 0.0f;
1667 return false;
1668 }
1669}
#define atan2
@ COLLIDER_FLAG_IGNORE_PLAYER
Definition enums.h:4281
@ ENTITY_TYPE_PUSH_BLOCK
Definition enums.h:2541
s32 test_ray_entities(f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *hitNx, f32 *hitNy, f32 *hitNz)
Test a general ray from a given starting position and direction against all entities.
Definition collision.c:947
s32 test_ray_colliders(s32 ignoreFlags, f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *hitNx, f32 *hitNy, f32 *hitNz)
Definition collision.c:768
#define NO_COLLIDER
Definition macros.h:167

Referenced by entity_switch_fall_down(), is_block_on_ground(), update_entity_shadow_position(), and update_npcs().

◆ set_standard_shadow_scale()

void set_standard_shadow_scale ( Shadow * shadow,
f32 height )

Definition at line 1671 of file entity.c.

1671 {
1673 shadow->scale.x = 0.13 - (height / 2600.0f);
1674 } else {
1675 shadow->scale.x = 0.12 - (height / 3600.0f);
1676 }
1677
1678 if (shadow->scale.x < 0.01) {
1679 shadow->scale.x = 0.01f;
1680 }
1681 shadow->scale.z = shadow->scale.x;
1682}

Referenced by make_item_entity(), make_item_entity_at_player(), update_item_entities(), update_nonplayer_actor_shadow(), update_player_actor_shadow(), and update_player_shadow().

◆ set_npc_shadow_scale()

void set_npc_shadow_scale ( Shadow * shadow,
f32 height,
f32 npcRadius )

Definition at line 1684 of file entity.c.

1684 {
1686 shadow->scale.x = 0.13 - (height / 2600.0f);
1687 } else {
1688 shadow->scale.x = 0.12 - (height / 3600.0f);
1689 }
1690
1691 if (shadow->scale.x < 0.01) {
1692 shadow->scale.x = 0.01f;
1693 }
1694
1695 if (npcRadius > 60.0f) {
1696 shadow->scale.z = shadow->scale.x * 2.0f;
1697 } else {
1698 shadow->scale.z = shadow->scale.x;
1699 }
1700}

Referenced by update_npcs().

◆ set_peach_shadow_scale()

void set_peach_shadow_scale ( Shadow * shadow,
f32 scale )

Definition at line 1702 of file entity.c.

1702 {
1704 f32 phi_f2 = 0.12f;
1705
1707 switch (playerStatus->anim) {
1709 case ANIM_Peach2_Thrown:
1710 case ANIM_Peach2_Land:
1712 shadow->scale.x = 0.26f - (scale / 2600.0f);
1713 if (shadow->scale.x < 0.01) {
1714 shadow->scale.x = 0.01f;
1715 }
1716 shadow->scale.z = 0.13f - (scale / 2600.0f);
1717 if (shadow->scale.z < 0.01) {
1718 shadow->scale.z = 0.01f;
1719 }
1720 return;
1721 }
1722
1723 phi_f2 = 0.16f;
1724 }
1725
1726 shadow->scale.x = phi_f2 - (scale / 3600.0f);
1727 if (shadow->scale.x < 0.01) {
1728 shadow->scale.x = 0.01f;
1729 }
1730 shadow->scale.z = shadow->scale.x;
1731}

Referenced by update_player_shadow().

◆ is_block_on_ground()

s32 is_block_on_ground ( Entity * block)

Definition at line 1733 of file entity.c.

1733 {
1734 f32 x = block->pos.x;
1735 f32 y = block->pos.y;
1736 f32 z = block->pos.z;
1737 f32 hitYaw;
1738 f32 hitPitch;
1739 f32 hitLength;
1740 s32 ret;
1741
1742 entity_raycast_down(&x, &y, &z, &hitYaw, &hitPitch, &hitLength);
1743
1744 ret = hitLength;
1745 if (ret == 32767) {
1746 ret = false;
1747 }
1748
1749 return ret;
1750}

Referenced by entity_base_block_idle(), entity_ItemBlock_replace_with_inactive(), and entity_shattering_init_pieces().

Variable Documentation

◆ D_8014AFB0

s32 D_8014AFB0 = 255

Definition at line 33 of file entity.c.

Referenced by clear_entity_data(), func_8010FE44(), and render_entities().

◆ CreateEntityVarArgBuffer

◆ gCurrentHiddenPanels

◆ gEntityHideMode

s32 gEntityHideMode

Definition at line 37 of file entity.c.

Referenced by clear_entity_data(), and render_entities().

◆ D_801512BC

s32 D_801512BC

Definition at line 39 of file entity.c.

Referenced by update_entities().

◆ D_80151304

s32 D_80151304

Definition at line 40 of file entity.c.

Referenced by clear_entity_data().

◆ D_80151344

s32 D_80151344

Definition at line 41 of file entity.c.

Referenced by clear_entity_data().

◆ entity_numEntities

s32 entity_numEntities

Definition at line 42 of file entity.c.

Referenced by clear_entity_data(), init_entity_data(), and update_entities().

◆ gEntityHeapBase

◆ gLastCreatedEntityIndex

s32 gLastCreatedEntityIndex

Definition at line 44 of file entity.c.

◆ gEntityHeapBottom

s32 gEntityHeapBottom

◆ entity_numShadows

s32 entity_numShadows

Definition at line 47 of file entity.c.

Referenced by clear_entity_data(), init_entity_data(), and update_shadows().

◆ isAreaSpecificEntityDataLoaded

s32 isAreaSpecificEntityDataLoaded

Definition at line 48 of file entity.c.

Referenced by clear_entity_data(), and load_area_specific_entity_data().

◆ entity_updateCounter

s32 entity_updateCounter

Definition at line 49 of file entity.c.

Referenced by clear_entity_data(), and update_entities().

◆ gWorldEntityList

BSS EntityList gWorldEntityList

Definition at line 51 of file entity.c.

Referenced by get_entity_list().

◆ gBattleEntityList

BSS EntityList gBattleEntityList

Definition at line 52 of file entity.c.

Referenced by get_entity_list().

◆ gCurrentEntityListPtr

◆ gWorldShadowList

BSS ShadowList gWorldShadowList

Definition at line 54 of file entity.c.

Referenced by get_shadow_list().

◆ gBattleShadowList

BSS ShadowList gBattleShadowList

Definition at line 55 of file entity.c.

Referenced by get_shadow_list().

◆ gCurrentShadowListPtr

BSS ShadowList* gCurrentShadowListPtr

◆ wEntityDataLoadedSize

BSS s32 wEntityDataLoadedSize

◆ bEntityDataLoadedSize

BSS s32 bEntityDataLoadedSize

Definition at line 59 of file entity.c.

Referenced by clear_entity_data(), load_simple_entity_data(), and load_split_entity_data().

◆ wEntityBlueprint

◆ bEntityBlueprint

BSS EntityBlueprint* bEntityBlueprint[4]

Definition at line 62 of file entity.c.

Referenced by clear_entity_data(), init_entity_data(), and is_entity_data_loaded().

◆ D_801516FC

BSS s32 D_801516FC

Definition at line 63 of file entity.c.

Referenced by clear_entity_data().

◆ BattleEntityHeapBottom

BSS u8 BattleEntityHeapBottom
extern