Esempio n. 1
0
        private void Awake()
        {
            var builder = new LayoutCollectionBuilder <IItemInstance>();

            collection = builder.SetLogger(_logger)
                         .SetSize(slotCount)
                         .SetSlotType <LayoutCollectionSlot <IItemInstance> >()
                         .SetName(_collectionName)
                         .SetColumnCount(_columnCount)
                         .Build();

            CollectionRegistry.byName.Register(collectionName, collection);
            CollectionRegistry.byID.Register(_guid.guid, collection);
            _logger.LogVerbose($"Created and registered collection with name {collectionName} and guid {_guid.guid}", this);
        }
//        public CollectionBuilder<TElementType> SetOwner(IIdentifiable owner)
//        {
//            throw new NotImplementedException();
//        }

        public LayoutCollection <TElementType> Build()
        {
            if (_size <= 0)
            {
                throw new ArgumentException("Can't build collection because size is 0 or lower.");
            }

            var col = new LayoutCollection <TElementType>(_size, _columnCount, _logger);

            col.GenerateSlots(_slotType);
            col.isReadOnly     = _isReadOnly;
            col.collectionName = _collectionName;
            col.restrictions   = _restrictions;

            return(col);
        }
Esempio n. 3
0
        protected override void RegisterByName(LayoutCollection <IItemInstance> col)
        {
            if (CollectionRegistry.byName.Contains(collectionName))
            {
                if (!ignoreDuplicates)
                {
                    _logger.Error($"Layout item collection with name {collectionName} already exists in CollectionRegistry", this);
                    return;
                }
                else
                {
                    _logger.Warning($"Layout item collection with name {collectionName} already exists in CollectionRegistry and will be overridden by this one. " +
                                    $"Use \"ignoreDuplicates = false\" to avoid collection override.", this);
                }
            }

            CollectionRegistry.byName.Register(collectionName, col);
        }
Esempio n. 4
0
 protected override void RegiterByID(LayoutCollection <IItemInstance> col)
 {
     CollectionRegistry.byID.Register(collectionID, col);
 }