Esempio n. 1
0
        public IStaticObject Create(ISector sector, HexNode node, int id)
        {
            if (sector is null)
            {
                throw new ArgumentNullException(nameof(sector));
            }

            var staticObject = new StaticObject(node, Purpose, id);

            // Все залежи изначально имеют пустой модуль контейнера.
            // Он будет заполняться по мере добычи.
            var containerModule = new DepositContainer();

            staticObject.AddModule(containerModule);

            var dropScheme    = _schemeService.GetScheme <IDropTableScheme>(_dropTableSchemeSid);
            var depositModule = new PropDepositModule(containerModule, dropScheme, _dropResolver, _toolTags,
                                                      ExhausingValue, Difficulty);

            staticObject.AddModule(depositModule);

            var lifetimeModule = new DepositLifetimeModule(sector.StaticObjectManager, staticObject);

            staticObject.AddModule(lifetimeModule);

            var durabilityModule = new DepositDurabilityModule(depositModule, lifetimeModule, 10);

            staticObject.AddModule(durabilityModule);

            return(staticObject);
        }
Esempio n. 2
0
        public void GivenЕстьСундукIdВЯчейкеСоСлучайнымЛутом(int chestId, int chestPosX, int chestPosY, Table table)
        {
            var schemeService       = Context.ServiceProvider.GetRequiredService <ISchemeService>();
            var sectorManager       = Context.ServiceProvider.GetRequiredService <ISectorManager>();
            var staticObjectManager = sectorManager.CurrentSector.StaticObjectManager;

            var nodeCoords = new OffsetCoords(chestPosX, chestPosY);
            var node       = sectorManager.CurrentSector.Map.Nodes.SelectByHexCoords(nodeCoords.X, nodeCoords.Y);

            var dropProps = new List <IProp>();

            foreach (var tableRow in table.Rows)
            {
                tableRow.TryGetValue("prop", out var propSchemeSid);
                tableRow.TryGetValue("count", out var resourceCount);

                var propScheme = schemeService.GetScheme <IPropScheme>(propSchemeSid);

                dropProps.Add(new Resource(propScheme, int.Parse(resourceCount)));
            }

            var dropResolverMock = new Mock <IDropResolver>();

            dropResolverMock.Setup(x => x.Resolve(It.IsAny <IEnumerable <IDropTableScheme> >()))
            .Returns(dropProps.ToArray());
            var dropResolver = dropResolverMock.Object;

            var chest        = new DropTablePropChest(System.Array.Empty <DropTableScheme>(), dropResolver);
            var staticObject = new StaticObject(node, chest.Purpose, chestId);

            staticObject.AddModule <IPropContainer>(chest);

            staticObjectManager.Add(staticObject);
        }
        public IPropContainer AddChest(int id, OffsetCoords nodeCoords)
        {
            var sector = GetCurrentGlobeFirstSector();

            var node         = sector.Map.Nodes.SelectByHexCoords(nodeCoords.X, nodeCoords.Y);
            var chest        = new FixedPropChest(Array.Empty <IProp>());
            var staticObject = new StaticObject(node, chest.Purpose, id);

            staticObject.AddModule <IPropContainer>(chest);

            sector.StaticObjectManager.Add(staticObject);

            return(chest);
        }