From f55811283628fd2a26fba90f3cb85f5c67b1c99e Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 11 Jan 2022 09:24:20 -0500 Subject: [PATCH] Refactor AI systems into AI module --- src/ai.rs | 7 +++++++ src/{ => ai}/animal_ai_system.rs | 2 +- src/{ => ai}/bystander_ai_system.rs | 4 ++-- src/{ => ai}/monster_ai_system.rs | 0 src/main.rs | 13 ++++--------- 5 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 src/ai.rs rename src/{ => ai}/animal_ai_system.rs (99%) rename src/{ => ai}/bystander_ai_system.rs (98%) rename src/{ => ai}/monster_ai_system.rs (100%) diff --git a/src/ai.rs b/src/ai.rs new file mode 100644 index 0000000..ebef657 --- /dev/null +++ b/src/ai.rs @@ -0,0 +1,7 @@ +mod animal_ai_system; +mod bystander_ai_system; +mod monster_ai_system; + +pub use animal_ai_system::AnimalAI; +pub use bystander_ai_system::BystanderAI; +pub use monster_ai_system::MonsterAI; diff --git a/src/animal_ai_system.rs b/src/ai/animal_ai_system.rs similarity index 99% rename from src/animal_ai_system.rs rename to src/ai/animal_ai_system.rs index 40cf4d7..b2eff2e 100644 --- a/src/animal_ai_system.rs +++ b/src/ai/animal_ai_system.rs @@ -1,10 +1,10 @@ use ::rltk::{DijkstraMap, DistanceAlg, Point}; use ::specs::prelude::*; -use super::{Map, RunState}; use crate::components::{ Carnivore, EntityMoved, Herbivore, Item, Position, Viewshed, WantsToMelee, }; +use crate::{Map, RunState}; pub struct AnimalAI {} diff --git a/src/bystander_ai_system.rs b/src/ai/bystander_ai_system.rs similarity index 98% rename from src/bystander_ai_system.rs rename to src/ai/bystander_ai_system.rs index f05e599..5352bcc 100644 --- a/src/bystander_ai_system.rs +++ b/src/ai/bystander_ai_system.rs @@ -1,9 +1,9 @@ use ::rltk::{Point, RandomNumberGenerator}; use specs::prelude::*; -use super::game_log::GameLog; -use super::{Map, RunState}; use crate::components::{Bystander, EntityMoved, Name, Position, Quips, Viewshed}; +use crate::game_log::GameLog; +use crate::{Map, RunState}; pub struct BystanderAI {} diff --git a/src/monster_ai_system.rs b/src/ai/monster_ai_system.rs similarity index 100% rename from src/monster_ai_system.rs rename to src/ai/monster_ai_system.rs diff --git a/src/main.rs b/src/main.rs index 31bf79e..d5117ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ -mod animal_ai_system; -mod bystander_ai_system; +mod ai; pub mod camera; mod components; mod damage_system; @@ -13,7 +12,6 @@ mod map; pub mod map_builders; mod map_indexing_system; mod melee_combat_system; -mod monster_ai_system; mod particle_system; mod player; pub mod random_table; @@ -31,8 +29,6 @@ extern crate lazy_static; use ::rltk::{GameState, Point, RandomNumberGenerator, Rltk}; use ::specs::prelude::*; use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator}; -use animal_ai_system::AnimalAI; -use bystander_ai_system::BystanderAI; use components::*; use damage_system::DamageSystem; pub use game_log::GameLog; @@ -43,7 +39,6 @@ use lighting_system::LightingSystem; pub use map::*; use map_indexing_system::MapIndexingSystem; use melee_combat_system::MeleeCombatSystem; -use monster_ai_system::MonsterAI; use particle_system::ParticleSpawnSystem; use player::*; pub use rect::Rect; @@ -115,16 +110,16 @@ impl State { let mut vis = VisibilitySystem {}; vis.run_now(&self.ecs); - let mut mob = MonsterAI {}; + let mut mob = ai::MonsterAI {}; mob.run_now(&self.ecs); let mut mapindex = MapIndexingSystem {}; mapindex.run_now(&self.ecs); - let mut animal = AnimalAI {}; + let mut animal = ai::AnimalAI {}; animal.run_now(&self.ecs); - let mut bystander = BystanderAI {}; + let mut bystander = ai::BystanderAI {}; bystander.run_now(&self.ecs); let mut triggers = TriggerSystem {};