Skip to content
Snippets Groups Projects
Verified Commit ee97680c authored by Louis's avatar Louis :fire:
Browse files

Support one-way routes

parent f2b9c64e
No related branches found
No related tags found
No related merge requests found
Pipeline #248 passed with stages
in 4 minutes and 36 seconds
...@@ -194,6 +194,7 @@ impl From<Vec<&EntityInstance>> for TownPaths { ...@@ -194,6 +194,7 @@ impl From<Vec<&EntityInstance>> for TownPaths {
let mut from_place = None; let mut from_place = None;
let mut to_place = None; let mut to_place = None;
let mut nodes: Vec<RouteNode> = Vec::new(); let mut nodes: Vec<RouteNode> = Vec::new();
let mut is_one_way = false;
for field in &entity.field_instances { for field in &entity.field_instances {
match &*field.identifier { match &*field.identifier {
...@@ -213,6 +214,11 @@ impl From<Vec<&EntityInstance>> for TownPaths { ...@@ -213,6 +214,11 @@ impl From<Vec<&EntityInstance>> for TownPaths {
}; };
} }
} }
"one_way" => {
if let Some(Value::Bool(val)) = &field.value {
is_one_way = *val;
}
}
_ => {} _ => {}
} }
} }
...@@ -229,16 +235,19 @@ impl From<Vec<&EntityInstance>> for TownPaths { ...@@ -229,16 +235,19 @@ impl From<Vec<&EntityInstance>> for TownPaths {
}, },
); );
let mut route_entry = routes.entry(to.clone()).or_insert_with(|| Destinations { if !is_one_way {
source: to.clone(), let mut route_entry =
routes: Default::default(), routes.entry(to.clone()).or_insert_with(|| Destinations {
}); source: to.clone(),
route_entry.routes.insert( routes: Default::default(),
from.clone(), });
Route { route_entry.routes.insert(
nodes: nodes.iter().rev().cloned().collect(), from.clone(),
}, Route {
); nodes: nodes.iter().rev().cloned().collect(),
},
);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment