Point no longer shown when already planted
This commit is contained in:
@@ -17,6 +17,7 @@ var region : Region
|
||||
var noise : Noise
|
||||
|
||||
var points : Array[Vector2]
|
||||
var point_occupied : Array[bool]
|
||||
|
||||
func _init(
|
||||
_region : Region
|
||||
@@ -34,6 +35,10 @@ func _process(delta):
|
||||
if refresh_timer > REFRESH_TIME:
|
||||
refresh_timer = 0
|
||||
points = get_grid_point()
|
||||
point_occupied.resize(len(points))
|
||||
for point_ind in range(len(points)):
|
||||
point_occupied[point_ind] = region.data.plants.any(func(plant_data):return points[point_ind].distance_to(plant_data.position) < 21)
|
||||
|
||||
var current_item = GameInfo.game_data.player_data.inventory.get_item()
|
||||
var target_opacity = (1.) if current_item and current_item.snap_usage_to_grid() else 0.
|
||||
|
||||
@@ -43,8 +48,9 @@ func _process(delta):
|
||||
0.1)
|
||||
|
||||
func _draw():
|
||||
for p in points:
|
||||
draw_point(p)
|
||||
for p_ind in range(len(points)):
|
||||
if not point_occupied[p_ind]:
|
||||
draw_point(points[p_ind])
|
||||
|
||||
|
||||
func get_grid_point() -> Array[Vector2]:
|
||||
|
||||
Reference in New Issue
Block a user