Exemple #1
0
        public FieldStringTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <FieldStringTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <FieldStringTemplateRepository>();

            var dir       = collection.Resolve("String/Map.img").ResolveAll();
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            dir.Children
            .SelectMany(n => n.Children)
            .Select(n =>
            {
                var id = Convert.ToInt32(n.Name);
                return(new TemplateProvider <FieldStringTemplate>(
                           id,
                           () => new FieldStringTemplate(
                               id,
                               n.ResolveAll()
                               )
                           ));
            })
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));

            logger.LogInformation($"Loaded {Count} field string templates in {stopwatch.Elapsed}");

            stopwatch.Stop();
        }
Exemple #2
0
        public MobTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <MobTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <MobTemplateRepository>();

            var dirMob    = collection.Resolve("Mob").ResolveAll();
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            dirMob.Children
            .Where(n => n.Name.Split(".")[0].All(char.IsDigit))
            .Select(n =>
            {
                var id = Convert.ToInt32(n.Name.Split(".")[0]);
                return(new TemplateProvider <MobTemplate>(
                           id,
                           () => new MobTemplate(
                               id,
                               n.ResolveAll(),
                               n.Resolve("info").ResolveAll()
                               )
                           ));
            })
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));

            logger.LogInformation($"Loaded {Count} mob templates in {stopwatch.Elapsed}");

            stopwatch.Stop();
        }
        public ItemOptionTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <ItemOptionTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <ItemOptionTemplateRepository>();

            var dirItemOptions = collection.Resolve("Item/ItemOption.img").ResolveAll();
            var stopwatch      = new Stopwatch();

            stopwatch.Start();

            dirItemOptions.Children
            .Select(n =>
            {
                var id = Convert.ToInt32(n.Name);
                return(new TemplateProvider <ItemOptionTemplate>(
                           id,
                           () => new ItemOptionTemplate(
                               id,
                               n.Resolve("info").ResolveAll(),
                               n.Resolve("level").ResolveAll()
                               )
                           ));
            })
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));

            logger.LogInformation($"Loaded {Count} item option templates in {stopwatch.Elapsed}");

            stopwatch.Stop();
        }
        public ContiMoveTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <ContiMoveTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <ContiMoveTemplateRepository>();

            var dir       = collection.Resolve("Server/Continent.img").ResolveAll();
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            dir.Children
            .Select(n =>
            {
                var id = Convert.ToInt32(n.Name);
                return(new TemplateProvider <ContiMoveTemplate>(
                           id,
                           () => new ContiMoveTemplate(
                               id,
                               n.ResolveAll(),
                               n.Resolve("field").ResolveAll(),
                               n.Resolve("scheduler").ResolveAll(),
                               n.Resolve("genMob")?.ResolveAll(),
                               n.Resolve("time").ResolveAll()
                               )
                           ));
            })
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));

            logger.LogInformation($"Loaded {Count} contimove templates in {stopwatch.Elapsed}");

            stopwatch.Stop();
        }
        public WorldTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <WorldTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <WorldTemplateRepository>();

            var dirWorld  = collection.Resolve("Server/World.img").ResolveAll();
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            dirWorld.Children
            .Select(n =>
            {
                var id = Convert.ToInt32(n.Name.Split(".")[0]);
                return(new TemplateProvider <WorldTemplate>(
                           id,
                           () => new WorldTemplate(
                               id,
                               n.ResolveAll()
                               )
                           ));
            })
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));

            logger.LogInformation($"Loaded {Count} world templates in {stopwatch.Elapsed}");

            stopwatch.Stop();
        }
Exemple #6
0
        public FieldTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <FieldTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <FieldTemplateRepository>();

            var dirMap    = collection.Resolve("Map/Map").ResolveAll();
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            dirMap.Children
            .Where(n => n.Name.StartsWith("Map"))
            .SelectMany(n => n.Children)
            .Select(n =>
            {
                var id = Convert.ToInt32(n.Name.Split(".")[0]);
                return(new TemplateProvider <FieldTemplate>(
                           id,
                           () => new FieldTemplate(
                               id,
                               n.Resolve("foothold").ResolveAll(),
                               n.Resolve("portal").ResolveAll(),
                               n.Resolve("ladderRope").ResolveAll(),
                               n.Resolve("life").ResolveAll(),
                               n.Resolve("info").ResolveAll()
                               )
                           ));
            })
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));

            logger.LogInformation($"Loaded {Count} field templates in {stopwatch.Elapsed}");

            stopwatch.Stop();
        }
        public ItemStringTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <ItemStringTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <ItemStringTemplateRepository>();

            var results   = new List <TemplateProvider <ItemStringTemplate> >();
            var dir       = collection.Resolve("String").ResolveAll();
            var dirEqp    = dir.Resolve("Eqp.img").ResolveAll();
            var dirEtc    = dir.Resolve("Etc.img").ResolveAll();
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var templatesEquip = dirEqp.Children
                                 .SelectMany(n => n.Children)
                                 .SelectMany(n => n.Children)
                                 .Where(c => c.Name.All(char.IsDigit))
                                 .Select(n =>
            {
                var id = Convert.ToInt32(n.Name);
                return(new TemplateProvider <ItemStringTemplate>(
                           id,
                           () => new ItemStringTemplate(
                               id,
                               n.ResolveAll()
                               )
                           ));
            })
                                 .DistinctBy(t => t.ID)
                                 .ToList();

            results.AddRange(templatesEquip);
            logger.LogInformation($"Loaded {templatesEquip.Count} equip item string templates in {stopwatch.Elapsed}");

            stopwatch.Reset();

            var templatesEtc = dirEtc.Children
                               .SelectMany(n => n.Children)
                               .Where(c => c.Name.All(char.IsDigit))
                               .Select(n =>
            {
                var id = Convert.ToInt32(n.Name);
                return(new TemplateProvider <ItemStringTemplate>(
                           id,
                           () => new ItemStringTemplate(
                               id,
                               n.ResolveAll()
                               )
                           ));
            })
                               .DistinctBy(t => t.ID)
                               .ToList();

            new[] { "Consume", "Ins", "Cash" }.ForEach(d =>
            {
                dir.Resolve($"{d}.img").Children
                .DistinctBy(c => c.Name)
                .Where(c => c.Name.All(char.IsDigit))
                .Select(n =>
                {
                    var id = Convert.ToInt32(n.Name);
                    return(new TemplateProvider <ItemStringTemplate>(
                               id,
                               () => new ItemStringTemplate(
                                   id,
                                   n.ResolveAll()
                                   )
                               ));
                })
                .DistinctBy(t => t.ID)
                .ForEach(templatesEtc.Add);
            });

            results.AddRange(templatesEtc);
            logger.LogInformation($"Loaded {templatesEtc.Count} bundle item string templates in {stopwatch.Elapsed}");

            stopwatch.Stop();

            results
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));
        }
        public ItemTemplateRepository(
            IDataDirectoryCollection collection,
            ILogger <ItemTemplateRepository> logger = null
            ) : base(CacheDuration)
        {
            logger ??= new NullLogger <ItemTemplateRepository>();

            var results      = new List <TemplateProvider <ItemTemplate> >();
            var dirCharacter = collection.Resolve("Character").ResolveAll();
            var dirItem      = collection.Resolve("Item").ResolveAll();

            var nodesEquip = new List <IDataProperty>()
            {
                dirCharacter.Resolve("Accessory"),
                dirCharacter.Resolve("Cap"),
                dirCharacter.Resolve("Cape"),
                dirCharacter.Resolve("Coat"),
                dirCharacter.Resolve("Dragon"),
                dirCharacter.Resolve("Glove"),
                dirCharacter.Resolve("Longcoat"),
                dirCharacter.Resolve("Mechanic"),
                dirCharacter.Resolve("Pants"),
                dirCharacter.Resolve("PetEquip"),
                dirCharacter.Resolve("Ring"),
                dirCharacter.Resolve("Shield"),
                dirCharacter.Resolve("Shoes"),
                dirCharacter.Resolve("TamingMob"),
                dirCharacter.Resolve("Weapon"),
            };
            var nodesItem = new List <IDataProperty>()
            {
                dirItem.Resolve("Cash"),
                dirItem.Resolve("Consume"),
                dirItem.Resolve("Etc"),
                dirItem.Resolve("Install"),
            };
            var nodesPet  = dirItem.Resolve("Pet");
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var templatesEquip = nodesEquip
                                 .SelectMany(n => n.Children)
                                 .Select(n =>
            {
                var id = Convert.ToInt32(n.Name.Split(".")[0]);
                return(new TemplateProvider <ItemTemplate>(
                           id,
                           () => new ItemEquipTemplate(id, n.Resolve("info").ResolveAll())
                           ));
            })
                                 .ToList();

            results.AddRange(templatesEquip);
            logger.LogInformation($"Loaded {templatesEquip.Count} equip item templates in {stopwatch.Elapsed}");

            stopwatch.Reset();

            var templatesItem = nodesItem
                                .SelectMany(n => n.Children)
                                .SelectMany(n => n.Children)
                                .Select(n =>
            {
                var id = Convert.ToInt32(n.Name);
                return(new TemplateProvider <ItemTemplate>(
                           id,
                           () => new ItemBundleTemplate(id, n.Resolve("info").ResolveAll())
                           ));
            })
                                .ToList();

            results.AddRange(templatesItem);
            logger.LogInformation($"Loaded {templatesItem.Count} bundle item templates in {stopwatch.Elapsed}");

            stopwatch.Reset();

            var templatesPet = nodesItem
                               .SelectMany(n => n.Children)
                               .Select(n =>
            {
                var id = Convert.ToInt32(n.Name.Split(".")[0]);
                return(new TemplateProvider <ItemTemplate>(
                           id,
                           () => new ItemPetTemplate(id, n.Resolve("info").ResolveAll())
                           ));
            })
                               .ToList();

            results.AddRange(templatesPet);
            logger.LogInformation($"Loaded {templatesPet.Count} pet item templates in {stopwatch.Elapsed}");

            stopwatch.Stop();

            results
            .DistinctBy(t => t.ID)
            .ForEach(t => Register(t));
        }