From 22c18205bcb3702ddf60f41f77f6f06554202f35 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sun, 22 Mar 2020 19:44:26 +0100 Subject: Updating gameplay starting mechanics, adding quadtree to map --- src/map.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/map.rs') diff --git a/src/map.rs b/src/map.rs index f977bec93e1d..212ce75100ad 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,31 +1,42 @@ //! Implements a map graph and world logic use crate::{ - data::{Link, Node}, - server::{ServerResult, ServerErr}, - wire::Response + config::{LinkCfg, MapCfg, NodeCfg}, + data::{Link, Node, NodeId}, + server::{ServerErr, ServerResult}, + wire::Response, }; use async_std::sync::Arc; -use serde::{Deserialize, Serialize}; +use quadtree_rs::Quadtree; use std::collections::BTreeMap; +pub struct MapNode { + pos: (f64, f64), + inner: Node, +} + /// A map that people fight on /// /// A map is defined by it's graph relationships, but also where on /// the map nodes are placed, how much spacing there is, etc. All /// this information is encoded in the same structs because it's /// static, and just more convenient. -#[derive(Default, Serialize, Deserialize)] pub struct Map { - /// Node IDs mapped to node objects - nodes: BTreeMap>, + /// Node IDs mapped to coordinates + nodes: BTreeMap, /// Link IDs mapped to link objects links: BTreeMap>, + /// A coordinate map for the network + coord: Quadtree>, } impl Map { - pub fn new() -> Arc { - Arc::new(Self::default()) + pub fn new() -> Self { + Self { + nodes: BTreeMap::new(), + links: BTreeMap::new(), + coord: Quadtree::new(2), + } } pub fn update(&mut self, cb: F) -> ServerResult -- cgit v1.2.3