Skip to content

Commit

Permalink
Fix formatting after #100
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Jan 14, 2024
1 parent a7193af commit b9ea9b5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
7 changes: 5 additions & 2 deletions source/match/Match.gd
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func _setup_player_units():
player, map.find_child("SpawnPoints").get_child(player_index).global_transform
)


func _spawn_player_units(player, spawn_transform):
_setup_and_spawn_unit(CommandCenter.instantiate(), spawn_transform, player, false)
_setup_and_spawn_unit(
Expand All @@ -149,7 +150,7 @@ func _setup_and_spawn_unit(unit, a_transform, player, mark_structure_under_const
unit.mark_as_under_construction()
_setup_unit_groups(unit, player)
player.add_child(unit)
if unit is Structure and mark_structure_under_construction:
if unit is Structure and mark_structure_under_construction:
navigation.update_terrain()
MatchSignals.unit_spawned.emit(unit)

Expand Down Expand Up @@ -208,9 +209,11 @@ func _conceal_player_units(player):
):
unit.remove_from_group("revealed_units")


func _on_unit_died(unit):
if unit is Structure:
navigation.update_terrain()



func _on_resource_depleted():
navigation.update_terrain()
2 changes: 1 addition & 1 deletion source/match/MatchSignals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ signal unit_targeted(unit)
signal unit_selected(unit)
signal unit_deselected(unit)
signal unit_died(unit)
signal resource_depleted()
signal resource_depleted
4 changes: 3 additions & 1 deletion source/match/Navigation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ func rebake(map):
obstacle.add_to_group("terrain_navigation_input")
_clear_static_obstacles()
_setup_static_obstacles()



func update_terrain():
terrain.rebake(true)


func _clear_static_obstacles():
for static_obstacle in _static_obstacles:
NavigationServer3D.free_rid(static_obstacle)
Expand Down
2 changes: 1 addition & 1 deletion source/match/TerrainNavigation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func _ready():
NavigationServer3D.map_force_update(navigation_map_rid)


func rebake(on_thread:bool):
func rebake(on_thread: bool):
_navigation_region.bake_navigation_mesh(on_thread)


Expand Down
19 changes: 11 additions & 8 deletions source/match/utils/UnitPlacementUtils.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
enum { VALID, COLLIDES_WITH_AGENT, NOT_NAVIGABLE }

const epsilon = 0.05 # Custom approximation variable check for terrain
const EPSILON = 0.05 # Custom approximation variable check for terrain


static func find_valid_position_radially(
Expand Down Expand Up @@ -81,14 +81,17 @@ static func validate_agent_placement_position(position, radius, existing_units,
position + Vector3(x, 0, z).normalized() * radius
)
for point_expected_to_be_navigable in points_expected_to_be_navigable:
if not (point_expected_to_be_navigable * Vector3(1, 0, 1)).distance_to(
(
NavigationServer3D.map_get_closest_point(
navigation_map_rid, point_expected_to_be_navigable
if not (
(point_expected_to_be_navigable * Vector3(1, 0, 1)).distance_to(
(
NavigationServer3D.map_get_closest_point(
navigation_map_rid, point_expected_to_be_navigable
)
* Vector3(1, 0, 1)
)
* Vector3(1, 0, 1)
)
) < epsilon :
)
< EPSILON
):
return NOT_NAVIGABLE
return VALID

Expand Down

0 comments on commit b9ea9b5

Please sign in to comment.