消除报错

This commit is contained in:
joylink_zhangsai 2023-09-21 17:45:58 +08:00
parent ffe638d20c
commit 1720d6ba5b

View File

@ -32,27 +32,15 @@ func CreateTurnoutEntries(world ecs.World, turnouts []*repository.Turnout, syste
for _, turnout := range turnouts {
var components []component.IComponentType
components = append(components, system.EntityIdentityComponent)
components = append(components, system.MovableObject1Component)
components = append(components, system.MovableObject2Component)
loadZdj9Double := turnout.SwitchMachineType() == proto.Turnout_ZDJ9_Double && systemTypeMap[system.SWITCH_ZDJ9_2]
if loadZdj9Double {
components = append(components, system.Switch2jZdj9StateComponent)
components = append(components, system.Switch2jZdj9CjStateComponent)
}
entry := world.Create(components...)
entries = append(entries, entry)
system.EntityIdentityComponent.Set(entry, &system.EntityIdentity{Id: turnout.Id()})
//J1
j1 := system.NewMovableObject()
j1.Value = system.J1Range
system.MovableObject1Component.Set(entry, j1)
//J2
j2 := system.NewMovableObject()
j2.Value = system.J2Range
system.MovableObject2Component.Set(entry, j2)
if loadZdj9Double {
system.Switch2jZdj9StateComponent.Set(entry, system.NewSwitch2jZdj9State())
system.Switch2jZdj9CjStateComponent.Set(entry, system.NewSwitch2jZdj9CjState())
}
}
return entries