Implemented R-Tree
Would like to switch the identifer of the hole to a random string.
This commit is contained in:
34
demo/assets/scripts/environment/destructable/holes.gd
Normal file
34
demo/assets/scripts/environment/destructable/holes.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends RefCounted
|
||||
|
||||
class_name Holes
|
||||
|
||||
var holes: Dictionary[int, Hole]
|
||||
var counter: int = 0
|
||||
|
||||
func _init() -> void:
|
||||
self.holes = {}
|
||||
|
||||
func add_hole(vectors: PackedVector2Array) -> Hole:
|
||||
var hole = Hole.new(counter, vectors)
|
||||
self.holes[counter] = hole
|
||||
counter += 1
|
||||
|
||||
return hole
|
||||
|
||||
func remove_hole(hole_id: int):
|
||||
self.holes.erase(hole_id)
|
||||
|
||||
func get_hole(hole_id: int) -> Hole:
|
||||
return self.holes[hole_id]
|
||||
|
||||
func get_hole_verticies() -> PackedVector2Array:
|
||||
var return_val: PackedVector2Array = []
|
||||
for hole in holes.values():
|
||||
return_val.append_array(hole.vectors)
|
||||
return return_val
|
||||
|
||||
func get_holes() -> Array[PackedVector2Array]:
|
||||
var return_val: Array[PackedVector2Array] = []
|
||||
for hole in holes.values():
|
||||
return_val.append(hole.vectors)
|
||||
return return_val
|
||||
Reference in New Issue
Block a user