rts-sim-module/simulation/simulation.go

40 lines
686 B
Go

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
}
func (s *Simulation) World() ecs.World {
return s.world
}
func (s *Simulation) Repo() *repository.Repository {
return s.repo
}
func CreateSimulation(repo *repository.Repository, world ecs.World) {
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]
}