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.
30 lines
871 B
GDScript
30 lines
871 B
GDScript
@tool
|
|
extends GridMap
|
|
class_name LevelGrid
|
|
|
|
@export_tool_button("打印item详情", "Callable")
|
|
var print_item: Callable = print_item_func
|
|
@export_group("替换item_id")
|
|
@export var id_from: int = 0
|
|
@export var id_to: int = 0
|
|
|
|
@export_tool_button("替换", "Callable")
|
|
var replace_id: Callable = replace_id_func
|
|
|
|
|
|
func print_item_func ()-> void:
|
|
var item_count_map: Dictionary = {}
|
|
for cell_position in get_used_cells():
|
|
var item_id: int = get_cell_item(cell_position)
|
|
if item_id in item_count_map:
|
|
item_count_map[item_id] += 1
|
|
else:
|
|
item_count_map[item_id] = 1
|
|
for item_id in item_count_map:
|
|
print("item_id:", item_id, ",count:", item_count_map[item_id])
|
|
|
|
|
|
func replace_id_func()->void:
|
|
for cell_position in get_used_cells():
|
|
if get_cell_item(cell_position) == id_from:
|
|
set_cell_item(cell_position, id_to, get_cell_item_orientation(cell_position)) |