fp: Add mob spawner and profiling metrics
This commit is contained in:
+19
-2
@@ -472,8 +472,6 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
||||
DQN_DEFER { Dqn_DSMap_Deinit(&astar_info); };
|
||||
|
||||
// NOTE: Enumerate the entities that are collidable ============================================
|
||||
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(arena);
|
||||
Dqn_List<FP_GameEntity const *> colliders = Dqn_List_Init<FP_GameEntity const *>(scratch.arena, 128);
|
||||
for (FP_GameEntityIterator it = {}; FP_Game_DFSPreOrderWalkEntityTree(game, &it, game->root_entity); ) {
|
||||
FP_GameEntity const *walk_entity = it.entity;
|
||||
if (entity == walk_entity->handle)
|
||||
@@ -606,6 +604,7 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
||||
return result;
|
||||
}
|
||||
|
||||
// NOTE: Spawning code =============================================================================
|
||||
static FP_GameEntityHandle FP_Game_EntityAddWallAtTile(FP_Game *game, Dqn_String8 name, Dqn_V2I tile_pos, Dqn_V2I size_in_tiles)
|
||||
{
|
||||
Dqn_V2 size = Dqn_V2_InitV2I(size_in_tiles * DQN_CAST(int32_t) game->tile_size);
|
||||
@@ -628,3 +627,21 @@ static FP_GameEntityHandle FP_Game_EntityAddWallAtTile(FP_Game *game, Dqn_String
|
||||
FP_GameEntityHandle result = entity->handle;
|
||||
return result;
|
||||
}
|
||||
|
||||
static FP_GameEntityHandle FP_Game_EntityAddMob(FP_Game *game, Dqn_V2 pos)
|
||||
{
|
||||
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Mob");
|
||||
entity->local_pos = pos;
|
||||
entity->size_scale = Dqn_V2_InitNx1(4);
|
||||
entity->sprite_sheet = &game->hero_sprite_sheet;
|
||||
entity->sprite_anims = game->hero_sprite_anims;
|
||||
entity->local_hit_box_size = Dqn_V2_InitV2I(game->hero_sprite_sheet.sprite_size);
|
||||
entity->flags |= FP_GameEntityFlag_Clickable;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByKeyboard;
|
||||
entity->flags |= FP_GameEntityFlag_MoveByMouse;
|
||||
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
||||
entity->stalk_entity = game->player;
|
||||
|
||||
FP_GameEntityHandle result = entity->handle;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user