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 {
let mut from_place = None;
let mut to_place = None;
let mut nodes: Vec<RouteNode> = Vec::new();
let mut is_one_way = false;
for field in &entity.field_instances {
match &*field.identifier {
......@@ -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 {
},
);
let mut route_entry = routes.entry(to.clone()).or_insert_with(|| Destinations {
source: to.clone(),
routes: Default::default(),
});
route_entry.routes.insert(
from.clone(),
Route {
nodes: nodes.iter().rev().cloned().collect(),
},
);
if !is_one_way {
let mut route_entry =
routes.entry(to.clone()).or_insert_with(|| Destinations {
source: to.clone(),
routes: Default::default(),
});
route_entry.routes.insert(
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