rts-sim-module/entities/relay_entity.go

22 lines
608 B
Go

package entities
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/system"
)
// CreateRelayEntity 创建继电器实体
func CreateRelayEntity(w ecs.World, relayId string) *ecs.Entry {
e := w.Create(system.EntityIdentityComponent, system.RelayStateComponent)
system.EntityIdentityComponent.Set(e, &system.EntityIdentity{Id: relayId})
system.RelayStateComponent.Set(e, system.NewRelayState())
return e
}
func CreateRelayEntries(world ecs.World, relays []*repository.Relay) {
for _, relay := range relays {
CreateRelayEntity(world, relay.Id())
}
}