summaryrefslogtreecommitdiff
path: root/src/resources/newentities.rs
blob: f03fbbb0b5c49eb3c874c976529dc75e26b06ccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

use crate::{
	Pos,
	Encyclopedia,
	Template,
	Result,
	componentwrapper::PreEntity
};

#[derive(Default)]
pub struct NewEntities {
	pub to_build: Vec<(Pos, PreEntity)>,
	pub encyclopedia: Encyclopedia
}

impl NewEntities {
	pub fn new(encyclopedia: Encyclopedia) -> Self {
		Self{
			to_build: Vec::new(),
			encyclopedia
		}
	}
	pub fn create(&mut self, pos: Pos, template: &Template) -> Result<()> {
		let components = self.encyclopedia.construct(template)?;
		self.to_build.push((pos, components));
		Ok(())
	}
}