private void CreateForTick(SimulationView simulationView, int tick) => _presentationRepository.Create(new Presentation.Sector { SimulationId = simulationView.Simulation.Id, Tick = tick, StarSystems = GetStarSystems(simulationView), StarSystemConnections = GetStarSystemConnections(simulationView.StarSystems) });
private IEnumerable <Presentation.StarSystem> GetStarSystems(SimulationView simulationView) { var controllingEmpires = GetControllingEmpires(simulationView); return(simulationView.StarSystems.Select(system => new Presentation.StarSystem { Coordinate = system.Coordinate, Development = system.Development, EmpireIds = controllingEmpires[system.Id] })); }
private Dictionary <ObjectId, List <ObjectId> > GetControllingEmpires(SimulationView simulationView) { var result = new Dictionary <ObjectId, List <ObjectId> >(); foreach (var system in simulationView.StarSystems) { result.Add(system.Id, new List <ObjectId>()); } foreach (var empire in simulationView.Empires) { foreach (var systemId in empire.StarSystemsIds) { result[systemId].Add(empire.Id); } } return(result); }