ambient_core 0.2.1

Ambient core functionality. Host-only.
Documentation
1
2
3
4
5
6
7
8
9
use ambient_ecs::{query, EntityId, World};

pub use ambient_ecs::generated::components::core::player::{local_user_id, player, user_id};

pub fn get_by_user_id(world: &World, user_id: &str) -> Option<EntityId> {
    // TODO: Consider a more efficient implementation that caches the players in a HashMap or similar
    // O(N) might get a bit finicky with large numbers of players
    query(self::user_id()).incl(player()).iter(world, None).find_map(|(id, uid)| if uid == user_id { Some(id) } else { None })
}