diff options
Diffstat (limited to 'stockton-types/src/world.rs')
-rw-r--r-- | stockton-types/src/world.rs | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/stockton-types/src/world.rs b/stockton-types/src/world.rs index e244aa7..e538d68 100644 --- a/stockton-types/src/world.rs +++ b/stockton-types/src/world.rs @@ -15,40 +15,20 @@ //! The thing you play on and all the associated state. -use crate::{EntityStore, Entity}; -use stockton_bsp::lumps::entities::Entity as BSPEntity; -use stockton_bsp::BSPFile; - use std::pin::Pin; -/// A live and playable world. There are two parts: The map, which has walls and other static objects, -/// and entities, which can move around and do things and are physics simulated. +use stockton_bsp::BSPFile; + +/// A loaded world. pub struct World<'a> { - pub map: Pin<Box<BSPFile<'a>>>, - pub live_entities: EntityStore, + pub map: Pin<Box<BSPFile<'a>>> } impl<'a> World<'a> { /// Create a new world from a BSPFile. - /// - /// Returns None if any entities in the map have name conflicts. - /// - /// `mapper` is called for each BSPEntity to map it to a concrete rust type. - pub fn new<F>(bsp: Pin<Box<BSPFile<'a>>>, mut mapper: F) -> Option<World<'a>> - where F: FnMut(&BSPEntity) -> Option<(Box<dyn Entity>, String)> { - - let mut entities: Vec<(Box<dyn Entity>, String)> = Vec::with_capacity(bsp.entities.entities.len()); - for bsp_ent in bsp.entities.entities.iter() { - if let Some(result) = mapper(&bsp_ent) { - entities.push(result); - } - } - - let store = EntityStore::from_entities(entities)?; - + pub fn new(bsp: Pin<Box<BSPFile<'a>>>) -> Option<World<'a>> { Some(World { - map: bsp, - live_entities: store + map: bsp }) } }
\ No newline at end of file |