Merge branch 'master' of https://git.code.tencent.com/jl-framework/rtss_simulation
This commit is contained in:
commit
6edff67117
@ -3,7 +3,6 @@ package entities
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/component"
|
|
||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/repository"
|
"joylink.club/rtsssimulation/repository"
|
||||||
@ -44,13 +43,7 @@ func CreateTurnoutEntries(world ecs.World, turnouts []*repository.Turnout) []*ec
|
|||||||
if len(turnout.RelayGroups()) == 0 {
|
if len(turnout.RelayGroups()) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var components []component.IComponentType
|
entries = append(entries, CreateSwitch2jzdj9Entity(world, turnout.Id()))
|
||||||
components = append(components, system.EntityIdentityComponent)
|
|
||||||
components = append(components, system.Switch2jZdj9StateComponent)
|
|
||||||
entry := world.Create(components...)
|
|
||||||
entries = append(entries, entry)
|
|
||||||
system.EntityIdentityComponent.Set(entry, &system.EntityIdentity{Id: turnout.Id()})
|
|
||||||
system.Switch2jZdj9StateComponent.Set(entry, system.NewSwitch2jZdj9State())
|
|
||||||
}
|
}
|
||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
@ -58,22 +51,22 @@ func CreateTurnoutEntries(world ecs.World, turnouts []*repository.Turnout) []*ec
|
|||||||
func TurnToNormal(worldId ecs.WorldId, turnoutId string) {
|
func TurnToNormal(worldId ecs.WorldId, turnoutId string) {
|
||||||
sim := simulation.FindSimulation(worldId)
|
sim := simulation.FindSimulation(worldId)
|
||||||
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, true)
|
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, true)
|
||||||
system.Switch2jZdj9DriveFc(sim.World(), turnoutId, true)
|
system.Switch2jZdj9DriveDc(sim.World(), turnoutId, true)
|
||||||
go func() {
|
go func() {
|
||||||
<-time.After(1 * time.Second)
|
<-time.After(5 * time.Second)
|
||||||
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, false)
|
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, false)
|
||||||
system.Switch2jZdj9DriveFc(sim.World(), turnoutId, false)
|
system.Switch2jZdj9DriveDc(sim.World(), turnoutId, false)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TurnToReverse(worldId ecs.WorldId, turnoutId string) {
|
func TurnToReverse(worldId ecs.WorldId, turnoutId string) {
|
||||||
sim := simulation.FindSimulation(worldId)
|
sim := simulation.FindSimulation(worldId)
|
||||||
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, true)
|
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, true)
|
||||||
system.Switch2jZdj9DriveDc(sim.World(), turnoutId, true)
|
system.Switch2jZdj9DriveFc(sim.World(), turnoutId, true)
|
||||||
go func() {
|
go func() {
|
||||||
<-time.After(1 * time.Second)
|
<-time.After(5 * time.Second)
|
||||||
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, false)
|
system.Switch2jZdj9DriveYc(sim.World(), turnoutId, false)
|
||||||
system.Switch2jZdj9DriveDc(sim.World(), turnoutId, false)
|
system.Switch2jZdj9DriveFc(sim.World(), turnoutId, false)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
package world
|
package world
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/entities"
|
"joylink.club/rtsssimulation/entities"
|
||||||
"joylink.club/rtsssimulation/repository"
|
"joylink.club/rtsssimulation/repository"
|
||||||
"joylink.club/rtsssimulation/simulation"
|
"joylink.club/rtsssimulation/simulation"
|
||||||
"joylink.club/rtsssimulation/system"
|
"joylink.club/rtsssimulation/system"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateSimulation(repo *repository.Repository) ecs.WorldId {
|
func CreateSimulation(repo *repository.Repository) ecs.WorldId {
|
||||||
var systems []ecs.ISystem
|
|
||||||
wc := &WorldConfig{
|
wc := &WorldConfig{
|
||||||
Systems: systems,
|
Systems: []ecs.ISystem{system.NewTimerSystem(), system.NewPercentageMovableSystem(), system.NewSwitch2jZdj9System(), system.NewRelaySystem()},
|
||||||
Tick: 200,
|
Tick: 200,
|
||||||
InitTime: time.Now(),
|
InitTime: time.Now(),
|
||||||
}
|
}
|
||||||
w := InitializeWorld(wc)
|
w := InitializeWorld(wc)
|
||||||
simulation.CreateSimulation(repo, w)
|
simulation.CreateSimulation(repo, w)
|
||||||
//添加实体
|
//添加实体
|
||||||
|
entities.CreateSystemTimerEntity(w, wc.InitTime)
|
||||||
entities.CreateTurnoutEntries(w, repo.TurnoutList())
|
entities.CreateTurnoutEntries(w, repo.TurnoutList())
|
||||||
entities.CreateRelayEntries(w, repo.RelayList())
|
entities.CreateRelayEntries(w, repo.RelayList())
|
||||||
//初始化组件
|
//初始化组件
|
||||||
|
Loading…
Reference in New Issue
Block a user