Rename to GameDB and GameDB::Level.
This commit is contained in:
parent
c46927ea10
commit
a20d701096
23 changed files with 142 additions and 151 deletions
56
systems.cpp
56
systems.cpp
|
@ -33,7 +33,7 @@ void System::set_position(World& world, SpatialMap& collision, Entity entity, Po
|
|||
}
|
||||
|
||||
void System::lighting() {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& light = *level.lights;
|
||||
auto& world = *level.world;
|
||||
auto& map = *level.map;
|
||||
|
@ -57,15 +57,15 @@ void System::lighting() {
|
|||
}
|
||||
|
||||
void System::generate_paths() {
|
||||
auto& level = Game::current();
|
||||
const auto &player_pos = Game::player_position();
|
||||
auto& level = GameDB::current();
|
||||
const auto &player_pos = GameDB::player_position();
|
||||
|
||||
level.map->set_target(player_pos.location);
|
||||
level.map->make_paths();
|
||||
}
|
||||
|
||||
void System::enemy_ai_initialize() {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& world = *level.world;
|
||||
auto& map = *level.map;
|
||||
|
||||
|
@ -93,10 +93,10 @@ void System::enemy_ai_initialize() {
|
|||
}
|
||||
|
||||
void System::enemy_pathing() {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& world = *level.world;
|
||||
auto& map = *level.map;
|
||||
const auto &player_pos = Game::player_position();
|
||||
const auto &player_pos = GameDB::player_position();
|
||||
|
||||
world.query<Position, Motion>([&](auto ent, auto &position, auto &motion) {
|
||||
if(ent != level.player) {
|
||||
|
@ -135,7 +135,7 @@ inline void move_entity(SpatialMap &collider, Map &game_map, Position &position,
|
|||
}
|
||||
|
||||
void System::motion() {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
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 = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
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 = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
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 = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& collider = *level.collision;
|
||||
auto& world = *level.world;
|
||||
auto& the_belt = world.get_the<ritual::Belt>();
|
||||
|
@ -237,7 +237,7 @@ void System::combat(int attack_id) {
|
|||
if(!the_belt.has(attack_id)) return;
|
||||
|
||||
auto& ritual = the_belt.get(attack_id);
|
||||
const auto& player_pos = Game::player_position();
|
||||
const auto& player_pos = GameDB::player_position();
|
||||
auto& player_combat = world.get<Combat>(level.player);
|
||||
|
||||
// this is guaranteed to not return the given position
|
||||
|
@ -286,10 +286,10 @@ void System::combat(int attack_id) {
|
|||
|
||||
|
||||
void System::collision() {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& collider = *level.collision;
|
||||
auto& world = *level.world;
|
||||
const auto& player_pos = Game::player_position();
|
||||
const auto& player_pos = GameDB::player_position();
|
||||
|
||||
// this is guaranteed to not return the given position
|
||||
auto [found, nearby] = collider.neighbors(player_pos.location);
|
||||
|
@ -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 = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
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,10 +328,10 @@ void System::remove_from_world(Entity entity) {
|
|||
}
|
||||
|
||||
void System::pickup() {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& world = *level.world;
|
||||
auto& collision = *level.collision;
|
||||
auto pos = Game::player_position();
|
||||
auto pos = GameDB::player_position();
|
||||
|
||||
if(!collision.something_there(pos.aiming_at)) return;
|
||||
|
||||
|
@ -393,8 +393,8 @@ void System::device(World &world, Entity actor, Entity item) {
|
|||
}
|
||||
|
||||
void System::plan_motion(Position move_to) {
|
||||
auto& level = Game::current();
|
||||
auto& player_pos = Game::player_position();
|
||||
auto& level = GameDB::current();
|
||||
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 = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& combat = level.world->get<Combat>(level.player);
|
||||
float percent = float(combat.hp) / float(combat.max_hp);
|
||||
|
||||
|
@ -423,7 +423,7 @@ void System::player_status() {
|
|||
}
|
||||
|
||||
std::shared_ptr<sf::Shader> System::sprite_effect(Entity entity) {
|
||||
auto world = Game::current_world();
|
||||
auto world = GameDB::current_world();
|
||||
if(world->has<SpriteEffect>(entity)) {
|
||||
auto& se = world->get<SpriteEffect>(entity);
|
||||
|
||||
|
@ -450,10 +450,10 @@ Entity System::spawn_item(World& world, const std::string& name) {
|
|||
}
|
||||
|
||||
void System::drop_item(Entity item) {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& world = *level.world;
|
||||
auto& map = *level.map;
|
||||
auto player_pos = Game::player_position();
|
||||
auto player_pos = GameDB::player_position();
|
||||
|
||||
dbc::check(map.can_move(player_pos.location), "impossible, the player can't be in a wall");
|
||||
|
||||
|
@ -470,7 +470,7 @@ void System::drop_item(Entity item) {
|
|||
|
||||
// NOTE: I think pickup and this need to be different
|
||||
bool System::place_in_container(Entity cont_id, const std::string& name, Entity world_entity) {
|
||||
auto world = Game::current_world();
|
||||
auto world = GameDB::current_world();
|
||||
auto& container = world->get<inventory::Model>(cont_id);
|
||||
|
||||
if(container.has(world_entity)) {
|
||||
|
@ -490,7 +490,7 @@ bool System::place_in_container(Entity cont_id, const std::string& name, Entity
|
|||
}
|
||||
|
||||
void System::remove_from_container(Entity cont_id, const std::string& slot_id) {
|
||||
auto world = Game::current_world();
|
||||
auto world = GameDB::current_world();
|
||||
auto& container = world->get<inventory::Model>(cont_id);
|
||||
auto entity = container.get(slot_id);
|
||||
container.remove(entity);
|
||||
|
@ -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 = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
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);
|
||||
|
@ -509,14 +509,14 @@ void System::inventory_swap(Entity container_id, const std::string& a_name, cons
|
|||
}
|
||||
|
||||
bool System::inventory_occupied(Entity container_id, const std::string& name) {
|
||||
auto world = Game::current_world();
|
||||
auto world = GameDB::current_world();
|
||||
auto& inventory = world->get<inventory::Model>(container_id);
|
||||
return inventory.has(name);
|
||||
}
|
||||
|
||||
|
||||
void System::draw_map(Matrix& grid, EntityGrid& entity_map) {
|
||||
auto& level = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
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 = Game::current();
|
||||
auto& level = GameDB::current();
|
||||
auto& world = *level.world;
|
||||
auto& inventory = world.get<inventory::Model>(level.player);
|
||||
auto& player_combat = world.get<Combat>(level.player);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue