diff options
Diffstat (limited to 'games/rstnode/rst-core/src/map.rs')
-rw-r--r-- | games/rstnode/rst-core/src/map.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/games/rstnode/rst-core/src/map.rs b/games/rstnode/rst-core/src/map.rs index 37f758b4a433..8c6578177e6c 100644 --- a/games/rstnode/rst-core/src/map.rs +++ b/games/rstnode/rst-core/src/map.rs @@ -1,17 +1,11 @@ //! Implements a map graph and world logic use crate::{ - config::{LinkCfg, MapCfg, NodeCfg}, data::{Link, Node, NodeId}, - server::{ServerErr, ServerResult}, wire::Response, }; use async_std::sync::Arc; -use quadtree_rs::{ - area::{Area, AreaBuilder}, - point::Point, - Quadtree, -}; +use quadtree_rs::{area::AreaBuilder, point::Point, Quadtree}; use std::collections::BTreeMap; pub struct MapNode { @@ -29,7 +23,7 @@ pub struct Map { /// Node IDs mapped to coordinates nodes: BTreeMap<NodeId, (i64, i64)>, /// Link IDs mapped to link objects - links: BTreeMap<u16, Arc<Link>>, + _links: BTreeMap<u16, Arc<Link>>, /// A coordinate map for the network coord: Quadtree<i64, Arc<MapNode>>, } @@ -38,16 +32,14 @@ impl Map { pub fn new() -> Self { Self { nodes: BTreeMap::new(), - links: BTreeMap::new(), + _links: BTreeMap::new(), coord: Quadtree::new(2), } } - pub fn update<F>(&mut self, cb: F) -> ServerResult<Response> - where - F: Fn(&mut Map) -> ServerResult<Response>, - { - unimplemented!() + /// Get the position of a node by its ID + pub fn node_position(&self, id: NodeId) -> Option<(i64, i64)> { + self.nodes.get(&id).cloned() } /// Get all objects that can be selected by a single point |