feat: 定时招募弹窗,开局5选3+定期3候选,配置驱动(GameConfig/RecruitPanel)

This commit is contained in:
2026-08-06 00:13:31 +08:00
parent a00c95af51
commit a3cbd738ad
10 changed files with 324 additions and 28 deletions
+32
View File
@@ -0,0 +1,32 @@
## 游戏全局配置(Autoload 单例)。
## 启动时从 resources/game_config.cfg 读取所有可调参数,
## 其他系统通过公开变量读取,如 GameConfig.recruit_interval_years。
extends Node
## 配置文件路径(res:// 开发期可改,导出后只读)。
const CONFIG_PATH := "res://resources/game_config.cfg"
# —— 招募系统(对应 cfg 的 [recruitment] 节)——
## 开局候选人数。
var opening_applicant_count := 5
## 开局必须选满数。
var opening_pick_count := 3
## 定期招募间隔(游戏年,1 年 = 360 天)。
var recruit_interval_years := 0.1
## 定期弹窗候选人数。
var recruit_applicant_count := 3
func _ready() -> void:
_load_config()
## 读取配置文件;缺失的项保持代码默认值,不会报错。
func _load_config() -> void:
var cfg := ConfigFile.new()
if cfg.load(CONFIG_PATH) != OK:
push_warning("GameConfig: 配置文件不存在,使用默认值")
return
opening_applicant_count = cfg.get_value("recruitment", "opening_applicant_count", opening_applicant_count)
opening_pick_count = cfg.get_value("recruitment", "opening_pick_count", opening_pick_count)
recruit_interval_years = cfg.get_value("recruitment", "recruit_interval_years", recruit_interval_years)
recruit_applicant_count = cfg.get_value("recruitment", "recruit_applicant_count", recruit_applicant_count)