extends Node3D class_name ItemManager var pt_count: int var pt_cache: int func _ready(): Global.item_mgr = self SignalManager.level_loading_start.connect(on_level_loading_start) func on_level_loading_start(): pass func create_pt(type: Enum.EPtType, value: int, pos: Vector3): value += pt_cache pt_cache = 0 if pt_count < 20: value = randi_range(int(0.5 * value), int(1.5 * value)) var pt_slice: Array[int] = [100, 50, 20, 10, 5, 2, 1] while value > 0: for i in pt_slice: if value < i: continue value -= i _create_pt(type, i, pos) break elif pt_count < 50: _create_pt(type, value, pos) else: pt_cache = value func destroy_pt(pt: PT): pt_count -= 1 pt.queue_free() func _create_pt(type: Enum.EPtType, value: int, pos: Vector3): pt_count += 1 var pt: PT = ResourceManager.scene_pt.instantiate() as PT pt.type = type pt.value = value add_child(pt) pt.position = pos