Example #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)
        {
            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 Character.CharacterPropertiesSpellBar)
            {
                if (property.SpellBarNumber == spellBarId && property.SpellBarIndex >= spellBarPositionId)
                {
                    property.SpellBarIndex++;
                }
            }

            var entity = new CharacterPropertiesSpellBar {
                CharacterId = Biota.Id, SpellBarNumber = spellBarId, SpellBarIndex = spellBarPositionId, SpellId = spellId
            };

            Character.CharacterPropertiesSpellBar.Add(entity);
            ChangesDetected = true;
        }
Example #2
0
 public void RemoveEntity(CharacterPropertiesSpellBar entity, Action <bool> callback)
 {
     _queue.Add(new Task(() =>
     {
         var result = _wrappedDatabase.RemoveEntity(entity);
         callback?.Invoke(result);
     }));
 }
Example #3
0
        public bool RemoveEntity(CharacterPropertiesSpellBar entity)
        {
            using (var context = new ShardDbContext())
            {
                context.CharacterPropertiesSpellBar.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);
                }
            }
        }