2025-09-21 13:56:50 +08:00
|
|
|
@tool
|
|
|
|
|
extends Node
|
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"):
|
2025-09-21 13:56:50 +08:00
|
|
|
itemTextures[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
2025-09-21 14:47:43 +08:00
|
|
|
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:
|
2025-09-21 16:35:49 +08:00
|
|
|
return MathTool.priority(themes.get(t, false), load("res://themes/%s.tres" % t))
|
2025-09-21 14:47:43 +08:00
|
|
|
static func getItemTexture(t: String) -> Texture2D:
|
|
|
|
|
return MathTool.priority(itemTextures.get(t, false), load("res://resources/items/%s.svg" % t))
|