1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-03 09:51:53 +08:00

refactor: 重构资源路径和组件结构

- 将attackstar.svg从UI目录移动到resources/common目录
- 将VerticalColorBar.tscn从UI/Variants目录移动到根components目录
- 将LaserSummoner.tscn从Bullets/Common目录移动到Bullets根目录
- 移除调试日志打印语句
- 优化ItemStore.gd的getTexture方法默认值处理
- 更新相关场景和脚本中的资源引用路径
- 添加FeedFilter调试工具组件
- 优化ComponentManager初始化逻辑
This commit is contained in:
2025-09-21 13:56:50 +08:00
parent d54c050be9
commit 4e3425eda9
16 changed files with 124 additions and 31 deletions
-1
View File
@@ -25,7 +25,6 @@ func _ready():
regenerateCards()
)
for i in len(ComponentManager.feeds):
print("正在从 %s 加载饲料卡" % ComponentManager.feeds[i])
var feed = ComponentManager.getFeed(i).instantiate() as Feed
feed.selected.connect(
func(applied: bool):
+70
View File
@@ -0,0 +1,70 @@
@tool
extends HBoxContainer
enum ComposeMode {
ALL,
ANY,
}
@export var targetFields: Array[FieldStore.Entity] = []
@export var targetTopics: Array[FeedName.Topic] = []
@export var composeMode: ComposeMode = ComposeMode.ALL
@export var clickToRefresh: bool = false
var lastState: bool = false
func _ready():
rebuild()
func _physics_process(_delta):
if clickToRefresh != lastState:
lastState = clickToRefresh
rebuild()
func rebuild():
for i in get_children():
i.queue_free()
var files = DirTool.listdir("res://components/Feeds/")
for file in files:
var feed = load(file).instantiate() as Feed
# 检查字段条件
var fieldPassed: bool = true
if !targetFields.is_empty():
fieldPassed = checkFieldCondition(feed)
# 检查主题条件
var topicPassed: bool = true
if !targetTopics.is_empty():
topicPassed = checkTopicCondition(feed)
# 如果两个条件都满足,则添加到容器中
if fieldPassed and topicPassed:
add_child(feed)
func checkFieldCondition(feed: Feed) -> bool:
var passed: bool = true
for targetField in targetFields:
var haveThis = false
for feedField in feed.fields:
if feedField == targetField:
haveThis = true
break
passed = haveThis
if composeMode == ComposeMode.ALL:
if not passed:
break
elif composeMode == ComposeMode.ANY:
if passed:
break
return passed
func checkTopicCondition(feed: Feed) -> bool:
var passed: bool = false
for targetTopic in targetTopics:
var haveThis = feed.topic == targetTopic
passed = haveThis
if passed:
break
return passed
+4 -3
View File
@@ -10,9 +10,10 @@ static func listdir(path: String) -> Array[String]:
var file_name = dir.get_next()
while file_name != "":
if file_name != "." and file_name != "..":
if file_name.get_extension() == "remap":
file_name = file_name.substr(0, len(file_name) - 6)
files.append(path + file_name)
if not file_name.get_extension() == "import":
if file_name.get_extension() == "remap":
file_name = file_name.substr(0, len(file_name) - 6)
files.append(path + file_name)
file_name = dir.get_next()
dir.list_dir_end()
return files
+2 -1
View File
@@ -1,4 +1,5 @@
@tool
extends Node
class_name ItemStore
enum ItemType {
@@ -23,4 +24,4 @@ static var idMap = {
ItemType.SOUL: "soul",
}
static func getTexture(type: ItemType) -> Texture2D:
return ComponentManager.getItemTexture(idMap[type])
return ComponentManager.getItemTexture(idMap.get(type, "baseball"))
+20 -17
View File
@@ -1,3 +1,5 @@
@tool
extends Node
class_name ComponentManager
static var bullets = {}
@@ -8,6 +10,9 @@ static var uiComponents = {}
static var themes = {}
static var itemTextures = {}
func _ready():
init()
static func init():
for i in DirTool.listdir("res://components/Bullets"):
bullets[DirTool.getBasenameWithoutExtension(i)] = load(i)
@@ -22,20 +27,18 @@ static func init():
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)
static func getBullet(name: String):
return bullets[name]
static func getCharacter(name: String):
return characters[name]
static func getEffect(name: String):
return effects[name]
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)
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]