Skip to main content

vitium_api/game/components/
mod.rs

1pub mod armor;
2pub mod char;
3pub mod container;
4pub mod edible;
5pub mod hp;
6pub mod item;
7pub mod melee;
8pub mod pos;
9mod prelude;
10pub mod ranged;
11
12use bevy_ecs::{entity::Entity, world::World};
13
14pub use prelude::*;
15
16pub fn serialize_entity(entity: Entity, world: &World) -> String {
17    let mut value = serde_json::Map::new();
18    if let Some(comp) = world.get::<Item>(entity) {
19        value.insert("Item".into(), serde_json::to_value(comp).unwrap());
20    }
21    serde_json::to_string(&value).unwrap()
22}