public void Insert(Character entity) { this.Collection.InsertOne(entity); //add shortcut general CharacterShortcut characterShortcutGeneral = new CharacterShortcut { Id = DatabaseManager.Instance.AutoIncrement <CharacterShortcut>(CharacterShortcutRepository.Instance.Collection), CharacterId = entity.Id, BarType = DofusProtocol.Enums.ShortcutBarEnum.GENERAL_SHORTCUT_BAR, ShortcutObjects = new List <DofusProtocol.Network.Types.Shortcut>() }; CharacterShortcutRepository.Instance.Insert(characterShortcutGeneral); //add shortcut spell CharacterShortcut characterShortcutSpell = new CharacterShortcut { Id = DatabaseManager.Instance.AutoIncrement <CharacterShortcut>(CharacterShortcutRepository.Instance.Collection), CharacterId = entity.Id, BarType = DofusProtocol.Enums.ShortcutBarEnum.SPELL_SHORTCUT_BAR, ShortcutObjects = new List <DofusProtocol.Network.Types.Shortcut>() }; CharacterShortcutRepository.Instance.Insert(characterShortcutSpell); }
public static void HandleShortcutBarAdd(ShortcutBarAddRequestMessage message, WorldClient client) { var bar = client.Character.GetShortcutBar((ShortcutBarEnum)message.barType); CharacterShortcut shortcut = ShortcutBar.GetCharacterShortcut(client.Character, message.shortcut); if (shortcut != null) { bar.Add(shortcut); } }
public void RemoveShortcut(CharacterShortcut shortcutBar, int slot) { if (shortcutBar == null) { return; } var shortcutObject = shortcutBar.ShortcutObjects.Find(x => x.slot == slot); if (shortcutObject != null) { shortcutBar.ShortcutObjects.Remove(shortcutObject); this.Update(shortcutBar); } }
public void AddShortcutObject(CharacterShortcut shortcutBar, Shortcut shortcutObject) { if (shortcutBar == null) { return; } if (shortcutBar.ShortcutObjects != null) { var slotAlreadyTaken = shortcutBar.ShortcutObjects.Find(x => x.slot == shortcutObject.slot); if (slotAlreadyTaken != null) { shortcutBar.ShortcutObjects.Remove(slotAlreadyTaken); } } shortcutBar.ShortcutObjects.Add(shortcutObject); this.Update(shortcutBar); }
public void Update(CharacterShortcut entity) { var updateFields = Builders <CharacterShortcut> .Update.Set("ShortcutObjects", entity.ShortcutObjects); this.Collection.UpdateOne(Builders <CharacterShortcut> .Filter.Eq(x => x.Id, entity.Id), updateFields); }
public void Insert(CharacterShortcut entity) { this.Collection.InsertOne(entity); }