nil_core/world/infrastructure/
mod.rs1mod building;
5mod storage;
6
7use crate::city::City;
8use crate::continent::{ContinentKey, Coord};
9use crate::error::Result;
10use crate::infrastructure::Infrastructure;
11use crate::infrastructure::building::BuildingId;
12use crate::world::World;
13
14impl World {
15 #[inline]
16 pub fn infrastructure(&self, key: impl ContinentKey) -> Result<&Infrastructure> {
17 self.city(key).map(City::infrastructure)
18 }
19
20 pub fn toggle_building(&mut self, coord: Coord, id: BuildingId, enabled: bool) -> Result<()> {
21 self
22 .continent
23 .city_mut(coord)?
24 .infrastructure_mut()
25 .building_mut(id)
26 .toggle(enabled);
27
28 self.emit_city_updated(coord);
29
30 Ok(())
31 }
32}