You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
	
	
		
			
				
					
						
							|  |  |  | extends Node3D | 
					
						
							|  |  |  | class_name ItemManager | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var pt_count: 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): | 
					
						
							|  |  |  | 	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 | 
					
						
							|  |  |  | 	else: | 
					
						
							|  |  |  | 		_create_pt(type, value, pos) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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 |