示例#1
0
 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)
 });
示例#2
0
        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]
            }));
        }
示例#3
0
        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);
        }