traaains/sim/track/node/
connection.rs1use bevy::ecs::entity::Entity;
2
3use crate::utils::Dir;
4
5#[derive(Clone, Debug)]
6pub enum ConnectionLocation {
7 Start,
8 End,
9}
10
11impl ConnectionLocation {
12 pub fn starting_index(&self) -> f32 {
13 match self {
14 ConnectionLocation::Start => 0.0,
15 ConnectionLocation::End => 1.0,
16 }
17 }
18
19 pub fn starting_dir(&self) -> Dir {
20 match self {
21 ConnectionLocation::Start => Dir::Positive,
22 ConnectionLocation::End => Dir::Negative,
23 }
24 }
25}
26
27#[derive(Clone, Debug)]
28pub struct Connection {
29 pub segment: Entity,
30 pub location: ConnectionLocation,
31 pub first_signal: Option<Entity>,
32}
33
34impl Connection {
35 pub fn new(segment: Entity, location: ConnectionLocation) -> Self {
36 Connection {
37 segment,
38 location,
39 first_signal: None,
40 }
41 }
42}