forked from DrInfy/sc2-pathlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connected areas to specified point can now be found
- Loading branch information
Showing
5 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use pyo3::prelude::*; | ||
|
||
use crate::{ | ||
helpers::round_point2, | ||
}; | ||
|
||
use super::{map::Map}; | ||
|
||
const DIFFERENCE: usize = 12; | ||
const Y_MULT: usize = 1000000; | ||
|
||
#[pymethods] | ||
impl Map { | ||
pub fn calculate_connections(&mut self, location: (f32, f32)) { | ||
let pf = self.get_map_mut(0); | ||
|
||
let result = pf.djiktra(location, 400f32); | ||
|
||
let width = self.ground_pathing.map.len(); | ||
let height = self.ground_pathing.map[0].len(); | ||
|
||
// Reset | ||
for x in 0..width { | ||
for y in 0..height { | ||
self.points[x][y].connected = false; | ||
} | ||
} | ||
|
||
// Set non ground connected locations | ||
for data_point in result { | ||
let point = data_point.0; | ||
self.points[point.0][point.1].connected = true; | ||
} | ||
} | ||
|
||
pub fn is_connected(&mut self, location: (f32, f32)) -> bool { | ||
let location_int = round_point2(location); | ||
return self.points[location_int.0][location_int.1].connected; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ pub mod influence; | |
pub mod map; | ||
pub mod map_point; | ||
pub mod zones; | ||
pub mod connections; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters