Fix note pool.
This commit is contained in:
@@ -37,6 +37,7 @@ func get_tap() -> TapNote:
|
||||
if tap == null:
|
||||
tap = _instantiate_tap()
|
||||
_used_taps[tap] = true
|
||||
tap.reset()
|
||||
return tap
|
||||
|
||||
## Return a tap note.
|
||||
@@ -50,6 +51,7 @@ func return_tap(tap: TapNote) -> void:
|
||||
"Returning tap note ", tap,
|
||||
" that was not spawned by pool ", self, "."
|
||||
)
|
||||
tap.reset()
|
||||
_free_taps.append(tap)
|
||||
|
||||
## Get a hold note. Instantiates one if no free nodes are available.
|
||||
@@ -58,6 +60,7 @@ func get_hold() -> HoldNote:
|
||||
if hold == null:
|
||||
hold = _instantiate_hold()
|
||||
_used_holds[hold] = true
|
||||
hold.reset()
|
||||
return hold
|
||||
|
||||
## Return a hold note.
|
||||
@@ -71,6 +74,7 @@ func return_hold(hold: HoldNote) -> void:
|
||||
"Returning hold note ", hold,
|
||||
" that was not spawned by pool ", self, "."
|
||||
)
|
||||
hold.reset()
|
||||
_free_holds.append(hold)
|
||||
|
||||
## Spawn the given number of notes.
|
||||
@@ -89,8 +93,11 @@ var _used_taps: Dictionary[TapNote, bool]
|
||||
var _free_holds: Array[HoldNote]
|
||||
var _used_holds: Dictionary[HoldNote, bool]
|
||||
|
||||
func _ready() -> void:
|
||||
reserve(tap_size, hold_size)
|
||||
|
||||
func _instantiate_tap() -> TapNote:
|
||||
return NoteScenes.get_tap(tap_skin).instantiate() as TapNote
|
||||
|
||||
func _instantiate_hold() -> HoldNote:
|
||||
return NoteScenes.get_tap(tap_skin).instantiate() as HoldNote
|
||||
return NoteScenes.get_hold(tap_skin).instantiate() as HoldNote
|
||||
|
||||
Reference in New Issue
Block a user