Skip to main content

place_segment

Function place_segment 

Source
pub fn place_segment(
    cmd: Commands<'_, '_>,
    v_segment: Single<'_, '_, (&mut VirtualSegment, &mut Transform, &mut Mesh2d)>,
    q_nodes: Query<'_, '_, (&mut TrackNode, &Transform), Without<VirtualSegment>>,
    q_segments: Query<'_, '_, &TrackSegment>,
    cursor_pos: Res<'_, CursorPos>,
    last_connected_block: ResMut<'_, LastConnectedBlock>,
    next_step: ResMut<'_, NextState<CurrentStep>>,
    meshes: ResMut<'_, Assets<Mesh>>,
    assets_manager: Res<'_, AssetsManager>,
)
Expand description

System triggered by clicking left mouse button when in FinalStep state. Relies on current cursor position instead of virtual node position, which removes the sync issues. Calculates and spawns any needed nodes and then uses the SpawnSegment command, which also takes care of connecting the nodes and logical blocks.