示例#1
0
 private async Task <WorldEntity> GetFullWorld(string worldGuid, ICrvServiceContext context)
 {
     return(await context.Worlds
            .Include(c => c.CityCollection).ThenInclude(c => c.BuildingCollection).ThenInclude(c => c.CargoCollection)
            .Include(c => c.PlayerCollection)
            .FirstOrDefaultAsync(c => c.Guid == worldGuid));
 }
示例#2
0
 private async Task DeleteExecutedClientCommands(ICrvServiceContext context)
 {
     if (Options.DeleteExecutedClientCommands)
     {
         await context.DeleteExecutedClientCommands();
     }
 }
 public WorldRepositoryEntity(ICrvServiceContext context)
 {
     Context = context;
 }
示例#4
0
        private async Task ProcessWorld(string worldGuid, ClientCommandEntity[] commands, ICrvServiceContext context)
        {
            var world = await GetFullWorld(worldGuid, context);

            IPlayer player           = null;
            var     processedPlayers = new List <string>();

            foreach (var command in commands)
            {
                if (player == null || !processedPlayers.Contains(player.Guid))
                {
                    player = world.PlayerCollection.FirstOrDefault(c => c.Guid == command.PlayerGuid);

                    if (player != null)
                    {
                        ProcessorsProvider.Process(player);
                        processedPlayers.Add(player.Guid);
                    }
                }

                ProcessorsProvider.ProcessClientCommand(command, world, player);
            }


            ProcessorsProvider.Process(world);
        }
示例#5
0
 public Instances(ICrvServiceContext context, INewInstanceFactory newInstanceFactory)
 {
     WorldRepository    = new WorldRepositoryEntity(context);
     ProcessorsProvider = new ProcessorsProvider(newInstanceFactory);
     NewWorldGenerator  = new NewWorldGenerator(newInstanceFactory, WorldRepository);
 }