修改创建实体接口
This commit is contained in:
parent
c0c86d0d4c
commit
283dac24a4
@ -17,8 +17,7 @@ func main() {
|
||||
w.AddSystem(turnoutSys)
|
||||
idcomp := ecs.IdComp
|
||||
entities := w.CreateMany(10, idcomp, system.TurnoutStateComp)
|
||||
for i, entity := range entities {
|
||||
entry := w.Entry(entity)
|
||||
for i, entry := range entities {
|
||||
idcomp.SetValue(entry, ecs.Id(fmt.Sprintf("%d", i)))
|
||||
var db bool
|
||||
var fb bool
|
||||
|
14
world.go
14
world.go
@ -27,9 +27,9 @@ type World interface {
|
||||
// Id returns the unique identifier for the world.
|
||||
Id() WorldId
|
||||
// Create creates a new entity with the specified components.
|
||||
Create(components ...donburi.IComponentType) Entity
|
||||
Create(components ...donburi.IComponentType) *Entry
|
||||
// CreateMany creates a new entity with the specified components.
|
||||
CreateMany(n int, components ...donburi.IComponentType) []Entity
|
||||
CreateMany(n int, components ...donburi.IComponentType) []*Entry
|
||||
// Entry returns an entry for the specified entity.
|
||||
Entry(entity Entity) *Entry
|
||||
// Remove removes the specified entity.
|
||||
@ -77,16 +77,16 @@ func (w *world) Id() WorldId {
|
||||
return WorldId(w.world.Id())
|
||||
}
|
||||
|
||||
func (w *world) Create(components ...donburi.IComponentType) Entity {
|
||||
func (w *world) Create(components ...donburi.IComponentType) *Entry {
|
||||
entity := w.world.Create(components...)
|
||||
return Entity{entity}
|
||||
return &Entry{w.world.Entry(entity)}
|
||||
}
|
||||
|
||||
func (w *world) CreateMany(n int, components ...donburi.IComponentType) []Entity {
|
||||
func (w *world) CreateMany(n int, components ...donburi.IComponentType) []*Entry {
|
||||
entitys := w.world.CreateMany(n, components...)
|
||||
ets := make([]Entity, len(entitys))
|
||||
ets := make([]*Entry, len(entitys))
|
||||
for i, e := range entitys {
|
||||
ets[i] = Entity{e}
|
||||
ets[i] = &Entry{w.world.Entry(e)}
|
||||
}
|
||||
return ets
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user