diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:20 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:20 +0100 |
commit | de0f306ffcdf540c16ff2f89d99790c7f2b541fc (patch) | |
tree | f84e4a898a74ac412b4b332eb7c8c842c1b6af04 /stockton-types | |
parent | f6c2f402e245c620f8f03dcf3aa6265fca6e8dcf (diff) |
refactor(render): remove old entity stuff from world type
Diffstat (limited to 'stockton-types')
-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 |