AgentSkillsCN

game-component

为本项目创建全新的游戏组件。当新增实体需要补充新的数据或行为时,可使用此技能。组件负责存储数据,而系统则对这些数据进行处理与运算。

SKILL.md
--- frontmatter
name: game-component
description: Create new game components for this project. Use when adding entities need new data/behavior. Components store data; systems process them.

Creating Game Components

Quick Steps

  1. Create component/<name>.go:
go
package component

import "github.com/TheLazyLemur/engine/engine/math"

type <Name>Data struct {
    Field1 float32      `inspector:"Label,min:0,max:100"`
    Field2 math.Vector3 `inspector:"Label,type:vector3"`
    Timer  float32      `json:"-"` // Runtime only
}

func New<Name>() <Name>Data {
    return <Name>Data{
        Field1: 10.0,
        Field2: math.Vector3Zero(),
    }
}
  1. Register in component/components.go:
go
var (
    <Name> = donburi.NewComponentType[<Name>Data]()
)
  1. Register in components.go:
go
engine.RegisterComponent(eng, "<Name>", gameComponent.<Name>)

Inspector Tags

TagEffect
inspector:"Label"Show with label
min:X,max:YSlider range
type:vector33D editor
type:eulerRotation editor
`type:dropdown,options:AB
registry:meshMesh picker
json:"-"Don't serialize

Patterns

Timer: Elapsed float32 json:"-" **State**: `State int `inspector:"...,type:dropdown" Reference: TargetID uint64