Esempio n. 1
0
        public async Task <IQueryable <Star> > GetSectorsAsync(long sxMin, long syMin, long sxMax, long syMax,
                                                               [Service] UniverseContext dbContext, [Service] GalaxyGenerator generator)
        {
            var existingSectors = (
                from s in dbContext.Stars
                where s.SectorX >= sxMin && s.SectorX <= sxMax && s.SectorY >= syMin && s.SectorY <= syMax
                group s by new { s.SectorX, s.SectorY }
                into g
                select new { g.Key.SectorX, g.Key.SectorY }).ToHashSet();

            for (long sx = sxMin; sx <= sxMax; ++sx)
            {
                for (long sy = syMin; sy <= syMax; ++sy)
                {
                    if (!existingSectors.Contains(new { SectorX = sx, SectorY = sy }))
                    {
                        await generator.GenerateSector(sx, sy, dbContext);
                    }
                }
            }

            return(dbContext.Stars
                   .Where(s =>
                          s.SectorX >= sxMin && s.SectorX <= sxMax && s.SectorY >= syMin && s.SectorY <= syMax));
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UniverseContext db)
        {
            db.Database.EnsureCreated();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(o => o
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowAnyOrigin());

            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();

            app.UseGraphQL()
            .UsePlayground();

            app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; });
        }
Esempio n. 3
0
 public GameUpdate(UniverseContext dbContext, GameConfiguration gameConfig)
 {
     _dbContext  = dbContext;
     _gameConfig = gameConfig;
 }
Esempio n. 4
0
 public IQueryable <Ship> GetShips([Service] UniverseContext dbContext) => dbContext.Ships;
Esempio n. 5
0
 public IQueryable <PlanetMeta> GetPlanetMeta([Service] UniverseContext dbContext) => dbContext.PlanetMetas;
Esempio n. 6
0
 public IQueryable <Planet> GetPlanet([Service] UniverseContext dbContext) => dbContext.Planets;
Esempio n. 7
0
 public IQueryable <Star> GetStars([Service] UniverseContext dbContext) => dbContext.Stars;