不带电路的信号机
This commit is contained in:
parent
ec53a8e204
commit
41a7f7a585
@ -5,6 +5,7 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"log/slog"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func LoadSignals(w ecs.World) error {
|
||||
signals := data.Repo.SignalList()
|
||||
for _, signal := range signals {
|
||||
groups := signal.RelayGroups()
|
||||
signalEntry := newSignalEntity(w, signal.Id(), data)
|
||||
signalEntry := newSignalEntity(w, signal, data)
|
||||
if len(groups) == 1 { //带电路的信号机,有且只有一个组合类型,组合类型与电路有关
|
||||
group := groups[0]
|
||||
elecs := group.Components()
|
||||
@ -56,20 +57,21 @@ func LoadSignals(w ecs.World) error {
|
||||
default:
|
||||
slog.Warn(fmt.Sprintf("id=[%s]的信号机,无效组合类型[%s]", signal.Id(), group.Code()))
|
||||
}
|
||||
} else { //不带电路的信号机
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLightsByModel(w, signal.Model()))
|
||||
} else {
|
||||
slog.Debug(fmt.Sprintf("id=[%s]的信号机,没有组合类型或组合类型个数不为1", signal.Id()))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 新建信号机实体
|
||||
func newSignalEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
||||
func newSignalEntity(w ecs.World, signal *repository.Signal, worldData *component.WorldData) *ecs.Entry {
|
||||
uid := signal.Id()
|
||||
entry, ok := worldData.EntityMap[uid]
|
||||
if !ok {
|
||||
entry = w.Entry(w.Create(component.UidType, component.SignalTag))
|
||||
entry = w.Entry(w.Create(component.UidType, component.SignalTag, component.SignalLightsType))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
component.SignalLightsType.Set(entry, newSignalLightsByModel(w, signal.Model()))
|
||||
worldData.EntityMap[uid] = entry
|
||||
}
|
||||
return entry
|
||||
|
@ -14,7 +14,6 @@ func loadSignal2xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
signalEntry.AddComponent(component.Signal2XH1ElectronicType)
|
||||
signalEntry.AddComponent(component.Signal2XH1LsqType)
|
||||
signalEntry.AddComponent(component.Signal2XH1LscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.Signal2XH1Electronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -33,7 +32,6 @@ func loadSignal2xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
component.Signal2XH1ElectronicType.Set(signalEntry, elecState)
|
||||
component.Signal2XH1LsqType.Set(signalEntry, &component.Signal2XH1Lsq{})
|
||||
component.Signal2XH1LscType.Set(signalEntry, &component.Signal2XH1Lsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag))
|
||||
//校验
|
||||
if elecState.Z2XH1_DDJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机2xh1,缺少元件DDJ", signal.Id())
|
||||
|
@ -14,7 +14,6 @@ func loadSignal3xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
signalEntry.AddComponent(component.Signal3XH1ElectronicType)
|
||||
signalEntry.AddComponent(component.Signal3XH1LsqType)
|
||||
signalEntry.AddComponent(component.Signal3XH1LscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.Signal3XH1Electronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -39,7 +38,6 @@ func loadSignal3xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
component.Signal3XH1ElectronicType.Set(signalEntry, elecState)
|
||||
component.Signal3XH1LsqType.Set(signalEntry, &component.Signal3XH1Lsq{})
|
||||
component.Signal3XH1LscType.Set(signalEntry, &component.Signal3XH1Lsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
//校验
|
||||
if elecState.Z3XH1_DDJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机3xh1,缺少元件DDJ", signal.Id())
|
||||
|
@ -14,7 +14,6 @@ func loadSignal3xh2(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
signalEntry.AddComponent(component.Signal3XH2ElectronicType)
|
||||
signalEntry.AddComponent(component.Signal3XH2LsqType)
|
||||
signalEntry.AddComponent(component.Signal3XH2LscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.Signal3XH2Electronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -37,7 +36,6 @@ func loadSignal3xh2(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
component.Signal3XH2ElectronicType.Set(signalEntry, elecState)
|
||||
component.Signal3XH2LsqType.Set(signalEntry, &component.Signal3XH2Lsq{})
|
||||
component.Signal3XH2LscType.Set(signalEntry, &component.Signal3XH2Lsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
//校验
|
||||
if elecState.Z3XH2_DDJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机3xh2,缺少元件DDJ", signal.Id())
|
||||
|
@ -14,7 +14,6 @@ func loadSignal3xh3(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
signalEntry.AddComponent(component.Signal3XH3ElectronicType)
|
||||
signalEntry.AddComponent(component.Signal3XH3LsqType)
|
||||
signalEntry.AddComponent(component.Signal3XH3LscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.Signal3XH3Electronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -37,7 +36,6 @@ func loadSignal3xh3(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
component.Signal3XH3ElectronicType.Set(signalEntry, elecState)
|
||||
component.Signal3XH3LsqType.Set(signalEntry, &component.Signal3XH3Lsq{})
|
||||
component.Signal3XH3LscType.Set(signalEntry, &component.Signal3XH3Lsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
//校验
|
||||
if elecState.Z3XH3_DDJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机3xh3,缺少元件DDJ", signal.Id())
|
||||
|
@ -14,7 +14,6 @@ func loadSignal3xh4(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
signalEntry.AddComponent(component.Signal3XH4ElectronicType)
|
||||
signalEntry.AddComponent(component.Signal3XH4LsqType)
|
||||
signalEntry.AddComponent(component.Signal3XH4LscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.Signal3XH4Electronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -35,7 +34,6 @@ func loadSignal3xh4(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
component.Signal3XH4ElectronicType.Set(signalEntry, elecState)
|
||||
component.Signal3XH4LsqType.Set(signalEntry, &component.Signal3XH4Lsq{})
|
||||
component.Signal3XH4LscType.Set(signalEntry, &component.Signal3XH4Lsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
//校验
|
||||
if elecState.Z3XH4_DDJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机3xh4,缺少元件DDJ", signal.Id())
|
||||
|
@ -14,7 +14,6 @@ func loadSignalDcxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
signalEntry.AddComponent(component.SignalDCXHElectronicType)
|
||||
signalEntry.AddComponent(component.SignalDCXHLsqType)
|
||||
signalEntry.AddComponent(component.SignalDCXHLscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.SignalDCXHElectronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -31,7 +30,6 @@ func loadSignalDcxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
component.SignalDCXHElectronicType.Set(signalEntry, elecState)
|
||||
component.SignalDCXHLsqType.Set(signalEntry, &component.SignalDCXHLsq{})
|
||||
component.SignalDCXHLscType.Set(signalEntry, &component.SignalDCXHLsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.AdTag, component.BdTag))
|
||||
//校验
|
||||
if elecState.DCXH_DJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机DCXH,缺少元件DJ", signal.Id())
|
||||
|
@ -14,7 +14,6 @@ func loadSignalJckxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.En
|
||||
signalEntry.AddComponent(component.SignalJCKXHElectronicType)
|
||||
signalEntry.AddComponent(component.SignalJCKXHLsqType)
|
||||
signalEntry.AddComponent(component.SignalJCKXHLscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.SignalJCKXHElectronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -33,7 +32,6 @@ func loadSignalJckxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.En
|
||||
component.SignalJCKXHElectronicType.Set(signalEntry, elecState)
|
||||
component.SignalJCKXHLsqType.Set(signalEntry, &component.SignalJCKXHLsq{})
|
||||
component.SignalJCKXHLscType.Set(signalEntry, &component.SignalJCKXHLsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.BdTag, component.UdTag))
|
||||
//校验
|
||||
if elecState.JCKXH_DJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机JCKXH,缺少元件DJ", signal.Id())
|
||||
|
@ -14,7 +14,6 @@ func loadSignalJdxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
signalEntry.AddComponent(component.SignalJDXHElectronicType)
|
||||
signalEntry.AddComponent(component.SignalJDXHLsqType)
|
||||
signalEntry.AddComponent(component.SignalJDXHLscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.SignalJDXHElectronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -35,7 +34,6 @@ func loadSignalJdxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
component.SignalJDXHElectronicType.Set(signalEntry, elecState)
|
||||
component.SignalJDXHLsqType.Set(signalEntry, &component.SignalJDXHLsq{})
|
||||
component.SignalJDXHLscType.Set(signalEntry, &component.SignalJDXHLsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
//校验
|
||||
if elecState.JDXH_DJ == nil {
|
||||
return fmt.Errorf("id=[%s]的信号机JDXH,缺少元件DJ", signal.Id())
|
||||
|
Loading…
Reference in New Issue
Block a user