roguelike-game/src/effects/targeting.rs

15 lines
329 B
Rust
Raw Normal View History

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
}