rts-sim-module/entities/button_entity.go
2023-09-27 16:16:51 +08:00

24 lines
940 B
Go

package entities
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/system"
)
// CreateSelfResetButtonEntity 创建自复位按钮实体
func CreateSelfResetButtonEntity(w ecs.World, buttonId string) *ecs.Entry {
e := w.Create(system.EntityIdentityComponent, system.ButtonStateComponent, system.ButtonSelfRestTag)
system.EntityIdentityComponent.Set(e, &system.EntityIdentity{Id: buttonId})
system.ButtonStateComponent.Set(e, system.NewButtonState())
system.ButtonSelfRestTag.Set(e, &system.ButtonSelfRestState{KeepAxTime: 0})
return e
}
// CreateNonResetButtonEntity 创建非自复位按钮实体
func CreateNonResetButtonEntity(w ecs.World, buttonId string) *ecs.Entry {
e := w.Create(system.EntityIdentityComponent, system.ButtonStateComponent, system.ButtonNonRestTag)
system.EntityIdentityComponent.Set(e, &system.EntityIdentity{Id: buttonId})
system.ButtonStateComponent.Set(e, system.NewButtonState())
return e
}