And finally fix some of the API names to make more sense in their current location.

This commit is contained in:
Zed A. Shaw 2025-08-20 23:49:30 -04:00
parent a20d701096
commit 7ffa6025ce
11 changed files with 74 additions and 99 deletions

View file

@ -33,7 +33,7 @@ void System::set_position(World& world, SpatialMap& collision, Entity entity, Po
}
void System::lighting() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& light = *level.lights;
auto& world = *level.world;
auto& map = *level.map;
@ -57,7 +57,7 @@ void System::lighting() {
}
void System::generate_paths() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
const auto &player_pos = GameDB::player_position();
level.map->set_target(player_pos.location);
@ -65,7 +65,7 @@ void System::generate_paths() {
}
void System::enemy_ai_initialize() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
auto& map = *level.map;
@ -93,7 +93,7 @@ void System::enemy_ai_initialize() {
}
void System::enemy_pathing() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
auto& map = *level.map;
const auto &player_pos = GameDB::player_position();
@ -135,7 +135,7 @@ inline void move_entity(SpatialMap &collider, Map &game_map, Position &position,
}
void System::motion() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
level.world->query<Position, Motion>(
[&](auto ent, auto &position, auto &motion) {
// don't process entities that don't move
@ -146,7 +146,7 @@ void System::motion() {
}
void System::distribute_loot(Position target_pos) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
auto& config = world.get_the<GameConfig>();
int inventory_count = Random::uniform(0, 3);
@ -171,7 +171,7 @@ void System::distribute_loot(Position target_pos) {
}
void System::death() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
auto player = world.get_the<Player>();
std::vector<Entity> dead_things;
@ -229,7 +229,7 @@ inline void animate_entity(World &world, Entity entity) {
}
void System::combat(int attack_id) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& collider = *level.collision;
auto& world = *level.world;
auto& the_belt = world.get_the<ritual::Belt>();
@ -286,7 +286,7 @@ void System::combat(int attack_id) {
void System::collision() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& collider = *level.collision;
auto& world = *level.world;
const auto& player_pos = GameDB::player_position();
@ -319,7 +319,7 @@ void System::collision() {
* from the world for say, putting into a container or inventory.
*/
void System::remove_from_world(Entity entity) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& item_pos = level.world->get<Position>(entity);
level.collision->remove(item_pos.location, entity);
// if you don't do this you get the bug that you can pickup
@ -328,7 +328,7 @@ void System::remove_from_world(Entity entity) {
}
void System::pickup() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
auto& collision = *level.collision;
auto pos = GameDB::player_position();
@ -393,7 +393,7 @@ void System::device(World &world, Entity actor, Entity item) {
}
void System::plan_motion(Position move_to) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& player_pos = GameDB::player_position();
player_pos.aiming_at = move_to.aiming_at;
@ -405,7 +405,7 @@ void System::plan_motion(Position move_to) {
void System::player_status() {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& combat = level.world->get<Combat>(level.player);
float percent = float(combat.hp) / float(combat.max_hp);
@ -450,7 +450,7 @@ Entity System::spawn_item(World& world, const std::string& name) {
}
void System::drop_item(Entity item) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
auto& map = *level.map;
auto player_pos = GameDB::player_position();
@ -498,7 +498,7 @@ void System::remove_from_container(Entity cont_id, const std::string& slot_id) {
void System::inventory_swap(Entity container_id, const std::string& a_name, const std::string &b_name) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
dbc::check(a_name != b_name, "Attempt to inventory swap the same slot, you should check this and avoid calling me.");
auto& inventory = level.world->get<inventory::Model>(container_id);
@ -516,7 +516,7 @@ bool System::inventory_occupied(Entity container_id, const std::string& name) {
void System::draw_map(Matrix& grid, EntityGrid& entity_map) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
Map &map = *level.map;
Matrix &fow = level.lights->$fow;
@ -606,7 +606,7 @@ void System::render_map(Matrix& tiles, EntityGrid& entity_map, sf::RenderTexture
}
bool System::use_item(const string& slot_name) {
auto& level = GameDB::current();
auto& level = GameDB::current_level();
auto& world = *level.world;
auto& inventory = world.get<inventory::Model>(level.player);
auto& player_combat = world.get<Combat>(level.player);