2023-08-04 11:02:08 +08:00
|
|
|
package ecs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/yohamta/donburi"
|
2023-10-09 11:12:05 +08:00
|
|
|
"github.com/yohamta/donburi/component"
|
2023-08-04 11:02:08 +08:00
|
|
|
)
|
|
|
|
|
2023-10-09 11:12:05 +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 {
|
2023-10-09 14:21:24 +08:00
|
|
|
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) {
|
2023-10-09 14:21:24 +08:00
|
|
|
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) {
|
2023-10-09 14:21:24 +08:00
|
|
|
c.ComponentType.SetValue(entry, value)
|
2023-08-04 11:02:08 +08:00
|
|
|
}
|