Started working on this 'arena tester' tool that would let me load an enemy and test them, but then realized I could just make it so I can spawn enemies in the game. I'm keeping the arena around as it will be useful later as a scriptable testing tool, but for now just spawn and test.
This commit is contained in:
parent
b6c1eba1b3
commit
4f090159ab
14 changed files with 524 additions and 58 deletions
|
@ -51,6 +51,36 @@ shared_ptr<gui::BossFightUI> LevelManager::create_bossfight(shared_ptr<DinkyECS:
|
|||
return make_shared<gui::BossFightUI>(world, boss_id);
|
||||
}
|
||||
|
||||
DinkyECS::Entity LevelManager::spawn_enemy(std::string named) {
|
||||
(void)named;
|
||||
auto& level = current();
|
||||
|
||||
auto &config = level.world->get_the<GameConfig>();
|
||||
auto entity_data = config.enemies[named];
|
||||
|
||||
WorldBuilder builder(*level.map, $components);
|
||||
|
||||
auto entity_id = builder.configure_entity_in_map(*level.world, entity_data, 0);
|
||||
|
||||
auto& entity_pos = level.world->get<Position>(entity_id);
|
||||
auto player_pos = level.world->get<Position>(level.player);
|
||||
|
||||
for(matrix::box it{level.map->walls(),
|
||||
player_pos.location.x, player_pos.location.y, 1}; it.next();)
|
||||
{
|
||||
if(level.map->can_move({it.x, it.y})) {
|
||||
// this is where we move it closer to the player
|
||||
entity_pos.location.x = it.x;
|
||||
entity_pos.location.y = it.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
level.collision->insert(entity_pos.location, entity_id);
|
||||
|
||||
return entity_id;
|
||||
}
|
||||
|
||||
size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
|
||||
auto world = clone_load_world(prev_world);
|
||||
auto scaling = scale_level();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue