15 lines
329 B
Rust
15 lines
329 B
Rust
|
use ::specs::prelude::*;
|
||
|
|
||
|
use crate::components::Position;
|
||
|
use crate::map::Map;
|
||
|
|
||
|
pub fn entity_position(ecs: &World, target: Entity) -> Option<i32> {
|
||
|
if let Some(pos) = ecs.read_storage::<Position>().get(target) {
|
||
|
let map = ecs.fetch::<Map>();
|
||
|
|
||
|
return Some(map.xy_idx(pos.x, pos.y) as i32);
|
||
|
}
|
||
|
|
||
|
None
|
||
|
}
|