grounds 读取优化

This commit is contained in:
cakipaul 2025-04-01 16:12:29 +08:00
parent 06e7054156
commit b20452a7cb

View File

@ -22,25 +22,17 @@ var ground: Ground2D
var display_mask_sec = 0.0 var display_mask_sec = 0.0
static func _static_init() -> void:
_read_grounds()
# 场景名字映射到路径 # 场景名字映射到路径
static var GROUND_SCENE_PATH_DICT = {} static var GROUND_SCENE_PATH_DICT = {
"c01_s05": "res://scene/ground/scene/c01/s05_院长房间.tscn",
"c01_s06": "res://scene/ground/scene/c01/s06_孤儿院长廊围墙.tscn",
static func _read_grounds() -> void: "c01_s07": "res://scene/ground/scene/c01/s07_书店外.tscn",
var scenes_dir = "res://scene/ground/scene/" "c01_s08": "res://scene/ground/scene/c01/s08_书店.tscn",
# read grounds "c01_s09": "res://scene/ground/scene/c01/s09_公寓楼外.tscn",
var dir = DirAccess.open(scenes_dir) "c01_s10": "res://scene/ground/scene/c01/s10_公寓楼道.tscn",
for c_dir in dir.get_directories(): "c01_s11": "res://scene/ground/scene/c01/s11_黄包车演出.tscn",
var c_path = scenes_dir + c_dir + "/" "c01_s12": "res://scene/ground/scene/c01/s12_书店外_诡异版.tscn",
for s_file in DirAccess.open(c_path).get_files(): }
if s_file.ends_with(".tscn"):
var s_path = c_path + s_file
GROUND_SCENE_PATH_DICT[c_dir.substr(0, 3) + "_" + s_file.substr(0, 3)] = s_path
func _ready() -> void: func _ready() -> void:
mask_layer.layer = GlobalConfig.CANVAS_LAYER_GROUND_MASK mask_layer.layer = GlobalConfig.CANVAS_LAYER_GROUND_MASK