jl-ecs/component.go

28 lines
634 B
Go
Raw Permalink Normal View History

2023-08-04 11:02:08 +08:00
package ecs
import (
"github.com/yohamta/donburi"
"github.com/yohamta/donburi/component"
2023-08-04 11:02:08 +08:00
)
type IComponentType = component.IComponentType
2023-08-04 11:02:08 +08:00
type ComponentType[T any] struct {
*donburi.ComponentType[T]
}
// Get returns component data from the entry.
func (c *ComponentType[T]) Get(entry *Entry) *T {
return c.ComponentType.Get(entry)
2023-08-04 11:02:08 +08:00
}
// Set sets component data to the entry.
func (c *ComponentType[T]) Set(entry *Entry, component *T) {
c.ComponentType.Set(entry, component)
2023-08-04 11:02:08 +08:00
}
// SetValue sets the value of the component.
func (c *ComponentType[T]) SetValue(entry *Entry, value T) {
c.ComponentType.SetValue(entry, value)
2023-08-04 11:02:08 +08:00
}