use specs::{saveload::MarkedBuilder, Builder, Entity, World, WorldExt}; use crate::{ components::{Fleet, MeetingPointOwned}, misc::{Persistence, WorldPersistence}, }; use super::Error; #[derive(Default, Clone)] pub struct FleetBuilder { owner: Option, } impl FleetBuilder { pub fn build(&self, world: &mut World) -> Result { let owner = self.owner.ok_or(Error::MissingValue("owner"))?; let meeting_point_owned = MeetingPointOwned::new(owner); let fleet = Fleet::new(); let entity = world .create_entity() .marked::<::Marker>() .with(meeting_point_owned) .with(fleet) .build(); Ok(entity) } pub fn owner(mut self, meeting_point: Entity) -> Self { self.owner = Some(meeting_point); self } }