1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

feat(调试工具): 添加武器过滤器组件并重构Feed过滤器

重构FeedFilter.gd使用Watcher类来管理状态,并添加新的WeaponFilter组件用于武器过滤
This commit is contained in:
2026-05-10 13:38:29 +08:00
parent 6e0d0ad89b
commit 0a5041348e
4 changed files with 33 additions and 16 deletions
+7
View File
@@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://dfajyj3000hpq"]
[ext_resource type="Script" uid="uid://uym0v2p43tm3" path="res://scripts/Debug/WeaponFilter.gd" id="1_0puhl"]
[node name="WeaponFilter" type="HBoxContainer" unique_id=1023830568]
script = ExtResource("1_0puhl")
clickToRebuild = true
+5 -16
View File
@@ -1,5 +1,5 @@
@tool
extends HBoxContainer
extends Control
enum ComposeMode {
ALL,
@@ -11,38 +11,28 @@ enum ComposeMode {
@export var composeMode: ComposeMode = ComposeMode.ALL
@export var clickToRefresh: bool = false
var lastState: bool = false
var state: Watcher = Watcher.new(false)
func _ready():
state.changed.connect(rebuild)
rebuild()
func _physics_process(_delta):
if clickToRefresh != lastState:
lastState = clickToRefresh
rebuild()
func _process(_delta):
state.setState(clickToRefresh)
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:
@@ -59,7 +49,6 @@ func checkFieldCondition(feed: Feed) -> bool:
if passed:
break
return passed
func checkTopicCondition(feed: Feed) -> bool:
var passed: bool = false
for targetTopic in targetTopics:
+20
View File
@@ -0,0 +1,20 @@
@tool
extends Control
@export var clickToRebuild: bool = false
var watcher = Watcher.new(false)
func _ready():
watcher.changed.connect(rebuild)
rebuild()
func _process(_delta):
watcher.setState(clickToRebuild)
func rebuild():
for i in get_children():
i.queue_free()
var files = DirTool.listdir("res://components/Weapons/")
for file in files:
var weapon = load(file).instantiate() as Weapon
add_child(weapon)
+1
View File
@@ -0,0 +1 @@
uid://uym0v2p43tm3