mcpField
G
game-developer

game-developer

github.com/farmage开发224288 次安装5 周前更新
代码仓库

关于 game-developer

game-developer 是用于规划和开发游戏的技能,提供 Unity 和 Unreal 工作流指导,重点涵盖性能分析、平台优化、测试与多人验证。

主要功能

  1. 01游戏架构与 ECS 模式
  2. 02Unity 和 Unreal 开发指导
  3. 03CPU、GPU 与内存分析
  4. 04对象池、LOD 与异步加载
  5. 05跨平台和多人游戏测试

适用场景

  1. 01规划游戏技术架构
  2. 02实现游戏核心机制
  3. 03排查性能瓶颈
  4. 04验证多人游戏行为

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/farmage/opencode-skills --skill game-developer

安装后在 Claude Code 中输入/game-developer确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
ecs-patterns.md
multiplayer-networking.md
performance-optimization.md
unity-patterns.md
unreal-cpp.md

详细介绍

游戏开发者

核心工作流

  1. 分析需求 — 确定游戏类型、平台、性能目标和多人游戏需求
  2. 设计架构 — 规划 ECS/组件系统,针对目标平台进行优化
  3. 实现 — 构建核心机制、图形、物理、AI 和网络功能
  4. 优化 — 分析性能并优化至 60+ FPS,尽量减少内存和电池消耗
    • ✅ 验证检查点: 运行 Unity Profiler 或 Unreal Insights;确认帧时间 ≤16 ms(60 FPS)后再继续。迭代识别并解决 CPU/GPU 瓶颈。
  5. 测试 — 跨平台测试、性能验证和多人游戏压力测试
    • ✅ 验证检查点: 确认压力负载下帧率稳定;发布前运行多人游戏延迟/不同步测试。

参考指南

根据上下文加载详细指南:

主题参考资料加载时机
Unity 开发references/unity-patterns.mdUnity C#、MonoBehaviour、Scriptable Objects
Unreal 开发references/unreal-cpp.mdUnreal C++、Blueprints、Actor 组件
ECS 与模式references/ecs-patterns.mdEntity Component System、游戏模式
性能references/performance-optimization.mdFPS 优化、性能分析、内存
网络references/multiplayer-networking.md多人游戏、客户端-服务端、延迟补偿

约束

必须做到
  • 在所有平台上达到 60+ FPS
  • 对频繁实例化的对象使用对象池
  • 实现 LOD 系统以优化性能
  • 定期分析性能(CPU、GPU、内存)
  • 对资源使用异步加载
  • 为游戏逻辑实现恰当的状态机
  • 缓存组件引用(避免在 Update 中调用 GetComponent)
  • 使用 delta time 实现与帧率无关的移动
禁止事项
  • 在紧密循环或 Update() 中调用 Instantiate/Destroy
  • 跳过性能分析和性能测试
  • 使用字符串比较标签(使用 CompareTag)
  • 在 Update/FixedUpdate 循环中分配内存
  • 忽略特定平台的限制(移动设备、主机)
  • 在 Update 循环中使用 Find 方法
  • 将游戏数值硬编码(使用 ScriptableObjects/数据文件)

输出模板

实现游戏功能时,请提供:

  1. 核心系统实现(ECS 组件、MonoBehaviour 或 Actor)
  2. 相关数据结构(ScriptableObjects、struct、配置)
  3. 性能注意事项和优化措施
  4. 对架构决策的简要说明

关键代码模式

对象池(Unity C#)
public class ObjectPool<T> where T : Component
{
    private readonly Queue<T> _pool = new();
    private readonly T _prefab;
    private readonly Transform _parent;

    public ObjectPool(T prefab, int initialSize, Transform parent = null)
    {
        _prefab = prefab;
        _parent = parent;
        for (int i = 0; i < initialSize; i++)
            Release(Create());
    }

    public T Get()
    {
        T obj = _pool.Count > 0 ? _pool.Dequeue() : Create();
        obj.gameObject.SetActive(true);
        return obj;
    }

    public void Release(T obj)
    {
        obj.gameObject.SetActive(false);
        _pool.Enqueue(obj);
    }

    private T Create() => Object.Instantiate(_prefab, _parent);
}
组件缓存(Unity C#)
public class PlayerController : MonoBehaviour
{
    // Cache all component references in Awake — never call GetComponent in Update
    private Rigidbody _rb;
    private Animator _animator;
    private PlayerInput _input;

    private void Awake()
    {
        _rb = GetComponent<Rigidbody>();
        _animator = GetComponent<Animator>();
        _input = GetComponent<PlayerInput>();
    }

    private void FixedUpdate()
    {
        // Use cached references; use deltaTime for frame-independence
        Vector3 move = _input.MoveDirection * (speed * Time.fixedDeltaTime);
        _rb.MovePosition(_rb.position + move);
    }
}
状态机(Unity C#)
public abstract class State
{
    public abstract void Enter();
    public abstract void Tick(float deltaTime);
    public abstract void Exit();
}

public class StateMachine
{
    private State _current;

    public void TransitionTo(State next)
    {
        _current?.Exit();
        _current = next;
        _current.Enter();
    }

    public void Tick(float deltaTime) => _current?.Tick(deltaTime);
}

// Usage example
public class IdleState : State
{
    private readonly Animator _animator;
    public IdleState(Animator animator) => _animator = animator;
    public override void Enter() => _animator.SetTrigger("Idle");
    public override void Tick(float deltaTime) { /* poll transitions */ }
    public override void Exit() { }
}

文档

评论

支持 Markdown