private static void check_tile( Game_Unit unit, Vector2 loc, int parent, int mov, Vector2 target_loc, OpenList <Vector2> open_list, ClosedListRoute <Vector2> closed_list, bool dijkstras = false, bool use_euclidean_distance = false) { // return if terrain type of this tile doesn't have stats //Yeti int move_cost = pathfinding_terrain_cost(unit, loc); bool pass; int h = 0; if (Doors.Contains(loc) && move_cost < 0) { // I don't quite understand why I left the move cost negative for doors //Debug move_cost = -10;// (unit.mov + 1) * 10; //Debug pass = true; h = (unit.mov + 1) * 10; } else { pass = passable(unit, loc, loc != target_loc) || (loc == target_loc && Global.game_map.is_off_map(target_loc, false)); } if (pass) { int g = move_cost + closed_list.get_g(parent); if (mov < 0 || g <= mov * 10) { h += (dijkstras ? 0 : distance(loc, target_loc, use_euclidean_distance)); // If fog and AI controlled and the unit can't see this tile //if (Global.game_map.fow && !unit.is_ally && !Global.game_map.fow_visibility[unit.team].Contains(loc)) //Debug if (Global.game_map.fow && Global.game_state.ai_active && !Global.game_map.fow_visibility[unit.team].Contains(loc)) { // Make the tile less desirable for the unit to cross h += unit.mov * 10; } int f = g + h; int on_list = open_list.search(loc); if (on_list > -1) { open_list.repoint(on_list, parent, f, g); } else { open_list.add_item(loc, parent, f, g, pass); } } } }