Beispiel #1
0
        public bool Add(Entity item)
        {
            if (!_entityContainer.Add(item))
            {
                return(false);
            }
            item.ParentId = this.GetEntity();
            var abilityData = item.Get <AbilityData>();

            if (abilityData == null)
            {
                var spellData = item.Get <SpellData>();
                if (spellData != null)
                {
                    AddSpell(spellData, item);
                }
            }
            else
            {
                AddAbility(abilityData, item);
            }
            item.Get <InventoryItem>().SetContainer(this);
            var msg = new ContainerStatusChanged(this, item);

            item.Post(msg);
            this.GetEntity().Post(msg);
            OnRefreshItemList.SafeInvoke();
            return(true);
        }
Beispiel #2
0
        public void Clear()
        {
            _entityContainer.Clear();
            var msg = new ContainerStatusChanged(this, null);

            this.GetEntity().Post(msg);
            OnRefreshItemList.SafeInvoke();
        }
Beispiel #3
0
 public void Clear()
 {
     _array.Clear();
     foreach (var entry in _entityLookup)
     {
         _cachePool.Store(entry.Value);
     }
     _entityLookup.Clear();
     OnRefreshItemList.SafeInvoke();
 }
        public bool Remove(Entity entity)
        {
            if (!_container.Contains(entity))
            {
                return(false);
            }
            var msg = new ContainerStatusChanged(null, entity);

            entity.Post(msg);
            this.GetEntity().Post(msg);
            OnRefreshItemList.SafeInvoke();
            return(true);
        }
Beispiel #5
0
 public bool Add(Entity entity)
 {
     if (!CanAdd(entity))
     {
         return(false);
     }
     if (!SetupNewEntity(entity))
     {
         return(false);
     }
     entity.Get <InventoryItem>().Index = _array.Add(GetCachedEntity(entity));
     OnRefreshItemList.SafeInvoke();
     return(true);
 }
Beispiel #6
0
        public bool Remove(Entity entity)
        {
            if (!_entityContainer.Add(entity))
            {
                return(false);
            }
            entity.Get <InventoryItem>()?.SetContainer(null);
            entity.ParentId = -1;
            var msg = new ContainerStatusChanged(null, entity);

            entity.Post(msg);
            this.GetEntity().Post(msg);
            OnRefreshItemList.SafeInvoke();
            return(true);
        }
Beispiel #7
0
 public bool Remove(Entity entity)
 {
     if (!Contains(entity))
     {
         return(false);
     }
     _array.Remove(entity);
     if (_entityLookup.TryGetValue(entity, out var cached))
     {
         _cachePool.Store(cached);
         _entityLookup.Remove(entity);
     }
     ProcessEntityRemoval(entity);
     OnRefreshItemList.SafeInvoke();
     return(true);
 }
Beispiel #8
0
 public bool Add(Entity entity, int index)
 {
     if (!CanAdd(entity))
     {
         return(false);
     }
     if (_array[index] != null)
     {
         return(false);
     }
     if (!SetupNewEntity(entity))
     {
         return(false);
     }
     _array.Set(index, GetCachedEntity(entity));
     entity.Get <InventoryItem>().Index = index;
     OnRefreshItemList.SafeInvoke();
     return(true);
 }
Beispiel #9
0
        public virtual bool Add(Entity entity)
        {
            if (entity == null)
            {
                return(false);
            }
            if (!CanAdd(entity))
            {
                return(false);
            }
            InventoryItem containerItem = entity.Get <InventoryItem>();

            if (RequiresInventoryComponent)
            {
                if (containerItem == null)
                {
                    return(false);
                }
                if (containerItem.Inventory != null)
                {
                    containerItem.Inventory.Remove(entity);
                }
            }
            if (containerItem != null)
            {
                containerItem.SetContainer(this);
            }
            _list.Add(entity);
            entity.ParentId = Owner;
            var msg = new ContainerStatusChanged(this, entity);

            entity.Post(msg);
            this.GetEntity().Post(msg);
            OnRefreshItemList.SafeInvoke();
            return(true);
        }
Beispiel #10
0
 public void ContainerChanged()
 {
     OnRefreshItemList.SafeInvoke();
 }
Beispiel #11
0
 public virtual void Clear()
 {
     _list.Clear();
     OnRefreshItemList.SafeInvoke();
 }