rts-sim-module/examples/main.go

51 lines
1.4 KiB
Go
Raw Normal View History

2023-09-28 15:38:18 +08:00
package main
import (
2023-12-26 14:45:41 +08:00
"joylink.club/ecs"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/repository/model/proto"
"joylink.club/rtsssimulation/sys"
2023-10-09 18:07:39 +08:00
"time"
2023-09-28 15:38:18 +08:00
rtss_simulation "joylink.club/rtsssimulation"
"joylink.club/rtsssimulation/repository"
)
func main() {
2023-12-26 14:45:41 +08:00
protoRepo := &proto.Repository{}
protoRepo.Id = "1"
protoRepo.Version = "V1"
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan1", FanType: proto.Fan_CommonFan})
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan2", FanType: proto.Fan_FcBypassFan})
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan3", FanType: proto.Fan_SoftStartFan})
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan4", FanType: proto.Fan_HighLowSpeedFan})
//
repo, _ := repository.BuildRepository(protoRepo)
sim, _ := newIscsSimulation(repo)
sim.StartUp()
sim.SetSpeed(1)
time.Sleep(8 * time.Second)
sim.Close()
time.Sleep(2 * time.Second)
}
func newIscsSimulation(repo *repository.Repository) (ecs.World, error) {
w := ecs.NewWorld(100)
sys.BindIscsSystem(w)
//
// 初始化世界数据单例组件
entity.LoadWorldData(w, repo)
err := entity.LoadIscs(w)
return w, err
}
///////////////////////////////////////////////////////
func main1() {
sim, _ := rtss_simulation.NewSimulation(&repository.Repository{})
sim.StartUp()
2023-10-09 18:07:39 +08:00
sim.SetSpeed(2)
time.Sleep(1 * time.Second)
sim.Close()
time.Sleep(2 * time.Second)
2023-09-28 15:38:18 +08:00
}