ecs接口变化,实体创建接口相应调整
This commit is contained in:
parent
6592c42a0c
commit
1dc64115db
@ -9,7 +9,7 @@ import (
|
|||||||
func NewDBQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
func NewDBQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||||
entry, ok := entityMap[uid]
|
entry, ok := entityMap[uid]
|
||||||
if !ok {
|
if !ok {
|
||||||
entry = w.Create(component.DBQTag, component.UidType, component.DBQStateType, component.CounterType)
|
entry = w.Entry(w.Create(component.DBQTag, component.UidType, component.DBQStateType, component.CounterType))
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
entityMap[uid] = entry
|
entityMap[uid] = entry
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]*
|
|||||||
model := proto.Relay_Model_name[int32(relay.Model())]
|
model := proto.Relay_Model_name[int32(relay.Model())]
|
||||||
entry, ok := entityMap[uid]
|
entry, ok := entityMap[uid]
|
||||||
if !ok {
|
if !ok {
|
||||||
entry = w.Create(component.RelayTag, component.UidType, component.RelayDriveType, component.BitStateType)
|
entry = w.Entry(w.Create(component.RelayTag, component.UidType, component.RelayDriveType, component.BitStateType))
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
if strings.Contains(model, "Y") { // 有极继电器
|
if strings.Contains(model, "Y") { // 有极继电器
|
||||||
entry.AddComponent(component.YjRelayTag)
|
entry.AddComponent(component.YjRelayTag)
|
||||||
|
@ -2,6 +2,7 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/consts"
|
"joylink.club/rtsssimulation/consts"
|
||||||
@ -65,7 +66,7 @@ func LoadSignals(w ecs.World) error {
|
|||||||
func newSignalEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
func newSignalEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
||||||
entry, ok := worldData.EntityMap[uid]
|
entry, ok := worldData.EntityMap[uid]
|
||||||
if !ok {
|
if !ok {
|
||||||
entry = w.Create(component.UidType)
|
entry = w.Entry(w.Create(component.UidType))
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
worldData.EntityMap[uid] = entry
|
worldData.EntityMap[uid] = entry
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ func LoadWorldData(w ecs.World, repo *repository.Repository) {
|
|||||||
if repo == nil {
|
if repo == nil {
|
||||||
panic("repo不能为nil")
|
panic("repo不能为nil")
|
||||||
}
|
}
|
||||||
entry := w.Create(component.WorldDataType)
|
entry := w.Entry(w.Create(component.WorldDataType))
|
||||||
component.WorldDataType.Set(entry, &component.WorldData{
|
component.WorldDataType.Set(entry, &component.WorldData{
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
Time: time.Now().UnixMilli(),
|
Time: time.Now().UnixMilli(),
|
||||||
|
@ -41,7 +41,7 @@ func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Ent
|
|||||||
// 加载道岔ZDJ9双机转辙机
|
// 加载道岔ZDJ9双机转辙机
|
||||||
func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
|
func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
|
||||||
// 加载转辙机
|
// 加载转辙机
|
||||||
entrys := w.CreateMany(2, component.ZzjStateType, component.TwoPositionTransformType)
|
entrys := ecs.Entries(w, w.CreateMany(2, component.ZzjStateType, component.TwoPositionTransformType))
|
||||||
// 给道岔添加转辙机引用组件
|
// 给道岔添加转辙机引用组件
|
||||||
entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{
|
entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{
|
||||||
ZzjList: entrys,
|
ZzjList: entrys,
|
||||||
@ -144,7 +144,7 @@ func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Ent
|
|||||||
func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
||||||
entry, ok := worldData.EntityMap[uid]
|
entry, ok := worldData.EntityMap[uid]
|
||||||
if !ok {
|
if !ok {
|
||||||
entry = w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType)
|
entry = w.Entry(w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType))
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
worldData.EntityMap[uid] = entry
|
worldData.EntityMap[uid] = entry
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
rtss_simulation "joylink.club/rtsssimulation"
|
rtss_simulation "joylink.club/rtsssimulation"
|
||||||
"joylink.club/rtsssimulation/repository"
|
"joylink.club/rtsssimulation/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rtss_simulation.NewSimulation(&repository.Repository{})
|
sim := rtss_simulation.NewSimulation(&repository.Repository{})
|
||||||
|
fmt.Println(sim.Id())
|
||||||
|
sim.StartUp()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user