2023-09-20 15:14:38 +08:00
|
|
|
package simulation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/repository"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
simulationManager = make(map[ecs.WorldId]*Simulation)
|
|
|
|
)
|
|
|
|
|
|
|
|
type Simulation struct {
|
|
|
|
world ecs.World
|
|
|
|
repo *repository.Repository
|
|
|
|
}
|
|
|
|
|
2023-09-26 10:25:00 +08:00
|
|
|
func (s *Simulation) World() ecs.World {
|
2023-09-20 15:14:38 +08:00
|
|
|
return s.world
|
|
|
|
}
|
|
|
|
|
2023-09-26 10:25:00 +08:00
|
|
|
func (s *Simulation) Repo() *repository.Repository {
|
2023-09-20 15:14:38 +08:00
|
|
|
return s.repo
|
|
|
|
}
|
|
|
|
|
2023-09-26 10:25:00 +08:00
|
|
|
func CreateSimulation(repo *repository.Repository, world ecs.World) {
|
2023-09-20 15:14:38 +08:00
|
|
|
sim := &Simulation{
|
|
|
|
world: world,
|
|
|
|
repo: repo,
|
|
|
|
}
|
|
|
|
simulationManager[world.Id()] = sim
|
|
|
|
}
|
|
|
|
|
|
|
|
func DestroySimulation(id ecs.WorldId) {
|
|
|
|
delete(simulationManager, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func FindSimulation(id ecs.WorldId) *Simulation {
|
|
|
|
return simulationManager[id]
|
|
|
|
}
|