1#![allow(dead_code)]
22
23pub mod catalog;
24pub mod environment_config;
25pub mod generator;
26pub mod lister;
27pub mod preset_config;
28pub mod profile;
29pub mod robot_generator;
30pub mod selector;
31pub mod validator;
32
33pub use catalog::EnvironmentCatalog;
34pub use environment_config::{
35 AmbientLight, CubeObject, DirectionalLight, DistanceUnit, EnvironmentConfig, EnvironmentDimensions,
36 EnvironmentFeatures, FloorFeature, GoalsFeature, ImageObject, LightingFeature, NpcsFeature, ObstaclesFeature,
37 SceneObject, SpawnPointsFeature, WallsFeature,
38};
39#[allow(unused_imports)]
40pub use lister::list_environments;
41pub use preset_config::PresetConfig;
42pub use profile::RobotProfile;
43pub use robot_generator::RobotGenerator;
44pub use selector::EnvironmentSelector;
45#[allow(unused_imports)]
46pub use validator::{validate_catalog, validate_config};
47
48use anyhow::{Context, Result};
49use std::path::Path;
50
51pub(crate) fn load_json<T: serde::de::DeserializeOwned>(path: &Path, description: &str) -> Result<T> {
58 let content =
59 std::fs::read_to_string(path).with_context(|| format!("Failed to read {description}: {}", path.display()))?;
60
61 serde_json::from_str(&content).with_context(|| format!("Failed to parse {description}: {}", path.display()))
62}
63
64pub fn generate_robot(config_path: &Path, output_path: &Path) -> Result<()> {
66 println!("š¤ Mecha10 Robot Generator\n");
67
68 let generator = RobotGenerator::from_config_file(config_path)?;
69 generator.generate(output_path)?;
70
71 println!("\nā
Robot generation complete!");
72 println!("\nOutput: {}", output_path.display());
73
74 Ok(())
75}