forked from blasthavers/blastmud
69 lines
2.1 KiB
Rust
69 lines
2.1 KiB
Rust
use crate::DResult;
|
|
|
|
use super::room::{room_list, Exit, ExitType, Room, SimpleExit, SimpleRoom};
|
|
use serde_yaml::to_writer;
|
|
use std::fs::File;
|
|
|
|
fn exit_to_simple_exit(exit: &Exit) -> Option<SimpleExit> {
|
|
match exit.exit_type {
|
|
ExitType::Free => {}
|
|
_ => return None,
|
|
}
|
|
Some(SimpleExit {
|
|
direction: exit.direction.clone(),
|
|
target: exit.target.clone(),
|
|
exit_climb: exit.exit_climb.clone(),
|
|
needs_scan: None,
|
|
needs_npc_cleared: None,
|
|
})
|
|
}
|
|
|
|
fn room_to_simpleroom(room: &Room) -> Option<SimpleRoom<()>> {
|
|
if room.enter_trigger.is_some() {
|
|
return None;
|
|
}
|
|
let mut simple_exits = vec![];
|
|
for ex in &room.exits {
|
|
match exit_to_simple_exit(&ex) {
|
|
None => return None,
|
|
Some(simp_ex) => simple_exits.push(simp_ex),
|
|
}
|
|
}
|
|
Some(SimpleRoom {
|
|
zone: room.zone.clone(),
|
|
secondary_zones: room.secondary_zones.clone(),
|
|
code: room.code.clone(),
|
|
name: room.name.clone(),
|
|
short: room.short.clone(),
|
|
grid_coords: room.grid_coords.clone(),
|
|
description: room.description.clone(),
|
|
exits: simple_exits,
|
|
should_caption: room.should_caption.clone(),
|
|
repel_npc: room.repel_npc.clone(),
|
|
item_flags: room.item_flags.clone(),
|
|
stock_list: room.stock_list.clone(),
|
|
rentable_dynzone: room.rentable_dynzone.clone(),
|
|
material_type: room.material_type.clone(),
|
|
has_power: room.has_power.clone(),
|
|
door_states: room.door_states.clone(),
|
|
wristpad_hack_allowed: room.wristpad_hack_allowed.clone(),
|
|
journal: room.journal.clone(),
|
|
scavtable: room.scavtable.clone(),
|
|
scan_code: room.scan_code.clone(),
|
|
effects: None,
|
|
environment: room.environment.clone(),
|
|
extra: (),
|
|
})
|
|
}
|
|
|
|
pub fn dump_static_content() -> DResult<()> {
|
|
let rooms: Vec<SimpleRoom<()>> = room_list()
|
|
.iter()
|
|
.filter_map(|r| room_to_simpleroom(r))
|
|
.collect();
|
|
|
|
let mut file = File::create("/tmp/rooms.yaml")?;
|
|
to_writer(&mut file, &rooms)?;
|
|
Ok(())
|
|
}
|