예제 #1
0
        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();
        }
예제 #2
0
        public TemplateManager(IDataDirectoryCollection collection)
        {
            _dictionary = new Dictionary <Type, ITemplateCollection>
            {
                [typeof(ItemOptionTemplate)]  = new ItemOptionTemplateCollection(collection),
                [typeof(SetItemInfoTemplate)] = new SetItemInfoTemplateCollection(collection),
                [typeof(ItemTemplate)]        = new ItemTemplateCollection(collection),
                [typeof(FieldTemplate)]       = new FieldTemplateCollection(collection),
                [typeof(NPCTemplate)]         = new NPCTemplateCollection(collection),

                [typeof(ItemStringTemplate)]  = new ItemStringTemplateCollection(collection),
                [typeof(FieldStringTemplate)] = new FieldStringTemplateCollection(collection),

                [typeof(ContinentTemplate)] = new ContinentTemplateCollection(collection),
                [typeof(FieldSetTemplate)]  = new FieldSetTemplateCollection(collection),

                [typeof(CommodityTemplate)]   = new CommodityTemplateCollection(collection),
                [typeof(CashPackageTemplate)] = new CashPackageTemplateCollection(collection),

                [typeof(NotSaleTemplate)]           = new NotSaleTemplateCollection(collection),
                [typeof(BestTemplate)]              = new BestTemplateCollection(collection),
                [typeof(CategoryDiscountTemplate)]  = new CategoryDiscountTemplateCollection(collection),
                [typeof(ModifiedCommodityTemplate)] = new ModifiedCommodityTemplateCollection(collection),
                [typeof(NPCShopTemplate)]           = new NPCShopTemplateCollection(collection)
            };
        }
        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();
        }
예제 #4
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();
        }
예제 #5
0
 public TemplateManager(IDataDirectoryCollection collection, TemplateCollectionType types)
 {
     _dictionary = new Dictionary <Type, ITemplateCollection>
     {
         [typeof(ItemTemplate)]              = new ItemTemplateCollection(collection),
         [typeof(FieldTemplate)]             = new FieldTemplateCollection(collection),
         [typeof(NPCTemplate)]               = new NPCTemplateCollection(collection),
         [typeof(MakeCharInfoTemplate)]      = new MakeCharInfoTemplateCollection(collection),
         [typeof(CommodityTemplate)]         = new CommodityTemplateCollection(collection),
         [typeof(CashPackageTemplate)]       = new CashPackageTemplateCollection(collection),
         [typeof(ModifiedCommodityTemplate)] = new ModifiedCommodityTemplateCollection(collection),
         [typeof(BestTemplate)]              = new BestTemplateCollection(collection),
         [typeof(NotSaleTemplate)]           = new NotSaleTemplateCollection(collection),
         [typeof(CategoryDiscountTemplate)]  = new CategoryDiscountTemplateCollection(collection),
         [typeof(SetItemInfoTemplate)]       = new SetItemInfoTemplateCollection(collection),
         [typeof(ItemOptionTemplate)]        = new ItemOptionTemplateCollection(collection),
         [typeof(MobTemplate)]               = new MobTemplateCollection(collection),
         [typeof(ContinentTemplate)]         = new ContinentTemplateCollection(collection),
         [typeof(ReactorTemplate)]           = new ReactorTemplateCollection(collection),
         [typeof(SkillTemplate)]             = new SkillTemplateCollection(collection),
         [typeof(QuestTemplate)]             = new QuestTemplateCollection(collection),
         [typeof(FieldStringTemplate)]       = new FieldStringTemplateCollection(collection),
         [typeof(ItemStringTemplate)]        = new ItemStringTemplateCollection(collection),
         [typeof(SkillStringTemplate)]       = new SkillStringTemplateCollection(collection),
         [typeof(QuestStringTemplate)]       = new QuestStringTemplateCollection(collection),
         [typeof(NPCShopTemplate)]           = new NPCShopTemplateCollection(collection),
         [typeof(RewardTemplate)]            = new RewardTemplateCollection(collection)
     }
     .Where(c => types.HasFlag(c.Value.Type))
     .ToImmutableDictionary(kv => kv.Key, kv => kv.Value);
 }
        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();
        }
예제 #7
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();
        }
예제 #8
0
 public ProgramHost(
     IOptions <ProgramConfig> options,
     IDataStore store,
     ICacheClient cache,
     IMessageBus messenger,
     IDataDirectoryCollection data,
     IScriptEngine scripting
     )
 {
     _config    = options.Value;
     _store     = store;
     _cache     = cache;
     _messenger = messenger;
     _data      = data;
     _scripting = scripting;
     _acceptors = new List <ITransportAcceptor>();
 }
예제 #9
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 ModifiedCommodityTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #11
0
 public NotSaleTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #12
0
 public SkillTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #13
0
 public MakeCharInfoTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
 public CashPackageTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
 public FieldStringTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
 protected AbstractLazyTemplateCollection(IDataDirectoryCollection collection)
 {
     Collection = collection;
     Templates  = new Dictionary <int, ITemplate>();
 }
 public AbstractEagerTemplateCollection(IDataDirectoryCollection collection)
 {
     Collection = collection;
     Templates  = new Dictionary <int, ITemplate>();
 }
        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 ReactorTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
 public CategoryDiscountTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #21
0
 public AbstractLazyTemplateCollection(IDataDirectoryCollection collection)
 {
     Collection = collection;
     _templates = new ConcurrentDictionary <int, ITemplate>();
 }
 public ItemOptionTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #23
0
 public QuestTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
 public NPCShopTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #25
0
 public SetItemInfoTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #26
0
 public ContinentTemplateCollection(IDataDirectoryCollection collection) : base(collection)
 {
 }
예제 #27
0
        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));
        }