2025-09-21 12:53:15 +08:00
|
|
|
class_name ComponentManager
|
|
|
|
|
|
2025-09-21 13:05:20 +08:00
|
|
|
static var bullets = {}
|
|
|
|
|
static var characters = {}
|
|
|
|
|
static var effects = {}
|
2025-09-21 13:34:51 +08:00
|
|
|
static var feeds = []
|
|
|
|
|
static var uiComponents = {}
|
|
|
|
|
static var themes = {}
|
|
|
|
|
static var itemTextures = {}
|
2025-09-21 13:05:20 +08:00
|
|
|
|
|
|
|
|
static func init():
|
|
|
|
|
for i in DirTool.listdir("res://components/Bullets"):
|
|
|
|
|
bullets[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
|
|
|
|
for i in DirTool.listdir("res://components/Characters"):
|
|
|
|
|
characters[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
|
|
|
|
for i in DirTool.listdir("res://components/Effects"):
|
|
|
|
|
effects[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
2025-09-21 13:34:51 +08:00
|
|
|
for i in DirTool.listdir("res://components/Feeds"):
|
|
|
|
|
feeds.append(load(i))
|
|
|
|
|
for i in DirTool.listdir("res://components/UI"):
|
|
|
|
|
uiComponents[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
|
|
|
|
for i in DirTool.listdir("res://themes"):
|
|
|
|
|
themes[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
|
|
|
|
for i in DirTool.listdir("res://resources/items"):
|
|
|
|
|
itemTextures[DirTool.getBasenameWithoutExtension(i)] = load("res://resources/items/%s" % i)
|
2025-09-21 13:05:20 +08:00
|
|
|
static func getBullet(name: String):
|
|
|
|
|
return bullets[name]
|
|
|
|
|
static func getCharacter(name: String):
|
|
|
|
|
return characters[name]
|
|
|
|
|
static func getEffect(name: String):
|
|
|
|
|
return effects[name]
|
2025-09-21 13:34:51 +08:00
|
|
|
static func getFeed(index: int):
|
|
|
|
|
return feeds[index]
|
|
|
|
|
static func getUIComponent(name: String):
|
|
|
|
|
return uiComponents[name]
|
|
|
|
|
static func getTheme(name: String):
|
|
|
|
|
return themes[name]
|
|
|
|
|
static func getItemTexture(name: String):
|
|
|
|
|
return itemTextures[name]
|
|
|
|
|
static func readResource(path: String):
|
|
|
|
|
return load("res://resources/%s" % path)
|