Auto-sync: 2026-04-26 12:02
This commit is contained in:
79
wiki/sources/godot-gameplay-scripter.md
Normal file
79
wiki/sources/godot-gameplay-scripter.md
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
title: "Godot Gameplay Scripter Agent Personality"
|
||||
type: source
|
||||
tags: ["godot", "gdscript", "game-development", "agent-personality"]
|
||||
date: 2026-04-26
|
||||
---
|
||||
|
||||
## Source File
|
||||
- [[Agent/agency-agents/game-development/godot/godot-gameplay-scripter.md]]
|
||||
|
||||
## Summary(用中文描述)
|
||||
- 核心主题:Godot 4 游戏逻辑脚本专家 Agent 人格定义,强调以软件架构师的纪律性构建游戏系统
|
||||
- 问题域:如何用 GDScript 2.0 和 C# 构建类型安全、信号驱动、可组合的游戏玩法系统
|
||||
- 方法/机制:严格静态类型 + 信号架构 + 组合优于继承 + 正确的 Autoload 使用模式 + GDScript/C# 互操作规范
|
||||
- 结论/价值:提供了一套完整的 Godot 4 游戏开发规范,包括命名约定、代码模式、工作流程和性能指标
|
||||
|
||||
## Key Claims(用中文描述)
|
||||
- GodotGameplayScripter Agent 以软件架构师的纪律性和独立游戏开发者的务实精神构建游戏玩法系统
|
||||
- GDScript 信号必须使用 snake_case 且携带类型化参数,C# 信号使用 PascalCase + EventHandler 后缀
|
||||
- 所有变量、函数参数和返回值必须显式类型化,禁止在生产代码中使用无类型 var
|
||||
- 组合优于继承:通过子节点附加组件(如 HealthComponent)优于创建继承层级
|
||||
- Autoload 仅用于真正的跨场景全局状态,不得包含游戏逻辑
|
||||
- 场景必须可独立实例化,不得假设父节点类型或兄弟节点存在
|
||||
|
||||
## Key Quotes
|
||||
> "Everything is a node — behavior is composed by adding nodes, not by multiplying inheritance depth"
|
||||
> 核心哲学:一切皆为节点,行为通过添加节点组合,而非增加继承深度
|
||||
|
||||
> "Adding the type here catches this bug at parse time instead of 3 hours into playtesting"
|
||||
> 类型安全即功能:在解析时捕获 bug,而非在测试 3 小时后发现
|
||||
|
||||
> "Don't add this to Player — make a component, attach it, wire the signal"
|
||||
> 通信风格:组合优于捷径,永远不要把逻辑直接加到 Player 上,而是创建组件
|
||||
|
||||
> "GDScript signals use snake_case; if you're in C#, it's PascalCase with EventHandler"
|
||||
> 语言感知:在 GDScript 中信号用 snake_case;在 C# 中用 PascalCase 加 EventHandler 后缀
|
||||
|
||||
## Key Concepts
|
||||
- [[Signal-Driven Architecture]]:信号驱动架构——通过信号解耦系统,避免直接方法调用,信号必须携带类型化参数
|
||||
- [[Static Typing in GDScript 2.0]]:GDScript 2.0 静态类型——所有变量、参数、返回值必须显式类型化,使用 typed arrays
|
||||
- [[Composition Over Inheritance]]:组合优于继承——通过附加子节点组件实现行为,而非创建继承层级
|
||||
- [[Event Bus Autoload]]:事件总线 Autoload——跨场景解耦通信的全局信号总线,只用于真正跨场景的事件
|
||||
- [[Type-Safe Signal Design]]:类型安全信号设计——信号命名遵循语言约定,参数必须类型化,连接时验证方法存在性
|
||||
- [[GDScript C# Interoperability]]:GDScript/C# 互操作——跨语言信号连接模式,类型转换和连接命名规范
|
||||
|
||||
## Key Entities
|
||||
- [[GDScript 2.0]]:Godot 4 默认脚本语言,支持静态类型、装饰器、改进的信号系统
|
||||
- [[C# (Godot)]]:Godot 4 支持的 .NET 脚本语言,通过 GodotSharp bindings 与引擎交互
|
||||
- [[GDExtension]]:Godot 4 原生扩展机制,允许用 C++ 编写性能关键系统并暴露给 GDScript
|
||||
- [[HealthComponent]]:健康组件示例——展示类型化信号声明、@export 属性、伤害/治疗逻辑的标准模式
|
||||
- [[EventBus]]:事件总线 Autoload——全局跨场景信号发射器,用于解耦通信
|
||||
|
||||
## Connections
|
||||
- [[GDScript 2.0]] ← uses ← [[Static Typing in GDScript 2.0]]
|
||||
- [[GDScript 2.0]] ← uses ← [[Type-Safe Signal Design]]
|
||||
- [[C# (Godot)]] ← uses ← [[Type-Safe Signal Design]]
|
||||
- [[EventBus]] ← implements ← [[Signal-Driven Architecture]]
|
||||
- [[HealthComponent]] ← demonstrates ← [[Composition Over Inheritance]]
|
||||
- [[GDExtension]] ← extends ← [[C# (Godot)]]
|
||||
|
||||
## Contradictions
|
||||
- 无已知冲突内容
|
||||
|
||||
## Technical Deliverables Summary
|
||||
|
||||
### 核心代码模式
|
||||
- **Typed Signal (GDScript)**:`signal health_changed(new_health: float)` + `died.emit()`
|
||||
- **Signal Bus Autoload**:`signal player_died` + `signal score_changed(new_score: int)`
|
||||
- **Typed Signal (C#)**:`[Signal] public delegate void HealthChangedEventHandler(float newHealth)`
|
||||
- **Composition Pattern**:`@onready var health: HealthComponent = $HealthComponent`
|
||||
- **Typed Array**:`var _active_enemies: Array[EnemyBase] = []`
|
||||
- **GDScript/C# Interop**:`health_component.HealthChanged.connect(_on_health_changed)`(PascalCase)
|
||||
|
||||
### 质量指标
|
||||
- 生产代码零无类型 var 声明
|
||||
- 所有信号参数显式类型化,无 Variant
|
||||
- 零运行时路径查找(所有 get_node 仅在 _ready 中通过 @onready)
|
||||
- 组件节点 < 200 行,每个处理一个游戏关注点
|
||||
- 所有场景可独立运行(F6 测试通过)
|
||||
Reference in New Issue
Block a user