Ejemplo n.º 1
0
        /// <summary>
        /// This method implements player spell bar management for - adding a spell to a specific spell bar (0 based) at a specific slot (0 based).
        /// </summary>
        public void HandleActionAddSpellFavorite(uint spellId, uint spellBarPositionId, uint spellBarId)
        {
            new ActionChain(this, () =>
            {
                var spells = GetSpellsInSpellBar((int)spellBarId);

                if (spellBarPositionId > spells.Count + 1)
                {
                    spellBarPositionId = (uint)(spells.Count + 1);
                }

                // We must increment the position of existing spells in the bar that exist on or after this position
                foreach (var property in Biota.BiotaPropertiesSpellBar)
                {
                    if (property.SpellBarNumber == spellBarId && property.SpellBarIndex >= spellBarPositionId)
                    {
                        property.SpellBarIndex++;
                    }
                }

                var entity = new BiotaPropertiesSpellBar {
                    ObjectId = Biota.Id, SpellBarNumber = spellBarId, SpellBarIndex = spellBarPositionId, SpellId = spellId, Object = Biota
                };

                Biota.BiotaPropertiesSpellBar.Add(entity);
                ChangesDetected = true;
            }).EnqueueChain();
        }
Ejemplo n.º 2
0
 public void RemoveEntity(BiotaPropertiesSpellBar entity, Action <bool> callback)
 {
     _queue.Add(new Task(() =>
     {
         var result = _wrappedDatabase.RemoveEntity(entity);
         callback?.Invoke(result);
     }));
 }
Ejemplo n.º 3
0
        public bool RemoveEntity(BiotaPropertiesSpellBar entity)
        {
            using (var context = new ShardDbContext())
            {
                context.BiotaPropertiesSpellBar.Remove(entity);

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    // Character name might be in use or some other fault
                    log.Error($"RemoveEntity failed with exception: {ex}");
                    return(false);
                }
            }
        }