1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

feat(组件管理): 重构组件加载逻辑并添加优先级函数

重构ComponentManager的get方法,使用MathTool.priority函数实现资源加载的优先级逻辑
将Wave类中的entity类型从PackedScene改为String,延迟加载角色资源
添加MathTool.priority静态方法用于处理空值情况
This commit is contained in:
2025-09-21 14:47:43 +08:00
parent 4a66a1754e
commit 84d286e2c5
3 changed files with 29 additions and 25 deletions
+16 -14
View File
@@ -28,17 +28,19 @@ static func init():
themes[DirTool.getBasenameWithoutExtension(i)] = load(i)
for i in DirTool.listdir("res://resources/items"):
itemTextures[DirTool.getBasenameWithoutExtension(i)] = load(i)
static func getBullet(t: String):
return bullets[t]
static func getCharacter(t: String):
return characters[t]
static func getEffect(t: String):
return effects[t]
static func getFeed(i: int):
return feeds[i]
static func getUIComponent(t: String):
return uiComponents[t]
static func getTheme(t: String):
return themes[t]
static func getItemTexture(t: String):
return itemTextures[t]
static func getBullet(t: String) -> PackedScene:
return MathTool.priority(bullets.get(t, false), load("res://components/Bullets/%s.tscn" % t))
static func getCharacter(t: String) -> PackedScene:
return MathTool.priority(characters.get(t, false), load("res://components/Characters/%s.tscn" % t))
static func getEffect(t: String) -> PackedScene:
return MathTool.priority(effects.get(t, false), load("res://components/Effects/%s.tscn" % t))
static func getFeed(i: int) -> PackedScene:
if i >= 0 and i < feeds.size():
return feeds[i]
return null
static func getUIComponent(t: String) -> PackedScene:
return MathTool.priority(uiComponents.get(t, false), load("res://components/UI/%s.tscn" % t))
static func getTheme(t: String) -> Theme:
return MathTool.priority(themes.get(t, false), load("res://themes/%s.tscn" % t))
static func getItemTexture(t: String) -> Texture2D:
return MathTool.priority(itemTextures.get(t, false), load("res://resources/items/%s.svg" % t))