use super::{area::*, graph::*, map::*, neutral::*};
use crate::*;
use std::cell::RefCell;
use std::collections::VecDeque;
use std::rc::Rc;
pub type Index = isize;
pub struct ChokePoint {
p_graph: Rc<RefCell<Graph>>,
pseudo: bool,
index: Index,
areas: (Rc<RefCell<Area>>, Rc<RefCell<Area>>),
nodes: [WalkPosition; 4],
nodes_in_area: [(WalkPosition, WalkPosition); 4],
geometry: VecDeque<WalkPosition>,
blocked: bool,
blocking_neutral: Option<Rc<dyn Neutral>>,
p_path_back_trace: Option<Rc<RefCell<ChokePoint>>>,
}
pub enum Node {
End1,
Middle,
End2,
NodeCount,
}
pub type Path = Vec<Rc<RefCell<ChokePoint>>>;
impl ChokePoint {
pub fn is_pseudo(&self) -> bool {
self.pseudo
}
pub fn get_areas(&self) -> (Rc<RefCell<Area>>, Rc<RefCell<Area>>) {
self.areas.clone()
}
pub fn center(&self) -> WalkPosition {
self.pos(Node::Middle)
}
pub fn pos(&self, n: Node) -> WalkPosition {
match n {
Node::End1 => self.nodes[0],
Node::Middle => self.nodes[1],
Node::End2 => self.nodes[2],
_ => panic!(),
}
}
pub fn pos_in_area(&self, n: Node, area: &mut Area) -> TilePosition {
unimplemented!();
}
pub fn geometry(&self) -> &VecDeque<WalkPosition> {
&self.geometry
}
pub fn blocked(&self) -> bool {
self.blocked
}
pub fn blocking_neutral(&self) -> Option<Rc<dyn Neutral>> {
self.blocking_neutral.clone()
}
pub fn distance_from(&self, cp: Rc<RefCell<ChokePoint>>) -> usize {
unimplemented!()
}
pub fn accessible_from(&self, cp: Rc<RefCell<ChokePoint>>) -> bool {
self.distance_from(cp) >= 0
}
pub fn get_path_to(&self, cp: Rc<RefCell<ChokePoint>>) -> &Path {
unimplemented!()
}
pub fn get_map(&self) -> Rc<RefCell<Map>> {
unimplemented!()
}
pub fn new(
graph: Rc<RefCell<Graph>>,
idx: Index,
area1: Rc<RefCell<Area>>,
area2: Rc<RefCell<Area>>,
geometry: VecDeque<WalkPosition>,
neutral: Option<Rc<dyn Neutral>>,
) {
unimplemented!();
}
pub fn on_blocking_neutral_destroyed(&mut self, neutral: Rc<dyn Neutral>) {
unimplemented!();
}
pub fn index(&self) -> Index {
self.index
}
pub fn path_back_trace(&self) -> Option<Rc<RefCell<ChokePoint>>> {
self.p_path_back_trace.clone()
}
pub fn set_path_back_trace(&mut self, p: Rc<RefCell<ChokePoint>>) {
self.p_path_back_trace = Some(p);
}
fn get_graph(&self) -> Rc<RefCell<Graph>> {
self.p_graph.clone()
}
}