/// <summary> /// Build a network representation of the <see cref="ActionSetShortcut"/>'s in the <see cref="ActionSet"/>. /// </summary> public ServerActionSet BuildServerActionSet() { var serverActionSet = new ServerActionSet { Index = Index, Unknown3 = 1, Result = LimitedActionSetResult.Ok }; for (UILocation i = 0; i < (UILocation)MaxActionCount; i++) { ActionSetShortcut action = GetShortcut(i); serverActionSet.Actions.Add(new ServerActionSet.Action { ShortcutType = action?.ShortcutType ?? ShortcutType.None, ObjectId = action?.ObjectId ?? 0, Location = new ItemLocation { // TODO: this might not be correct, what about shortcuts that aren't spells? Location = action != null ? InventoryLocation.Ability : (InventoryLocation)300, // no idea why 300, this is what retail did BagIndex = (uint)(action?.Location ?? i) } }); } return(serverActionSet); }
/// <summary> /// Remove shortcut from <see cref="ActionSet"/> at supplied <see cref="UILocation"/>. /// </summary> public void RemoveShortcut(UILocation location) { ActionSetShortcut shortcut = GetShortcut(location); if (shortcut == null) { throw new ArgumentException($"Failed to remove shortcut from {location}, location isn't occupied!"); } if (shortcut.ShortcutType == ShortcutType.Spell) { checked { TierPoints += CalculateTierCost(shortcut.Tier); } } if (shortcut.PendingCreate) { actions.Remove(location); } else { shortcut.EnqueueDelete(true); saveMask |= ActionSetSaveMask.ActionSetActions; } log.Trace($"Removed shortcut {shortcut.ShortcutType} {shortcut.ObjectId} at {location} from action set {Index}."); }
/// <summary> /// Return <see cref="ActionSetShortcut"/> with supplied <see cref="ShortcutType"/> and object id. /// </summary> public ActionSetShortcut GetShortcut(ShortcutType type, uint objectId) { ActionSetShortcut shortcut = actions.Values .Where(a => !a.PendingDelete) .SingleOrDefault(a => a.ShortcutType == type && a.ObjectId == objectId); return(shortcut); }
/// <summary> /// Add shortcut to <see cref="ActionSet"/> from an existing database model. /// </summary> public void AddShortcut(CharacterActionSetShortcutModel model) { var shortcut = new ActionSetShortcut(this, model); if (shortcut.ShortcutType == ShortcutType.Spell) { checked { TierPoints -= CalculateTierCost(model.Tier); } } actions.Add(shortcut.Location, shortcut); }
/// <summary> /// Update a <see cref="ShortcutType.Spell"/> shortcut with supplied tier. /// </summary> public void UpdateSpellShortcut(uint spell4BaseId, byte tier) { ActionSetShortcut shortcut = GetShortcut(ShortcutType.Spell, spell4BaseId); if (shortcut == null) { throw new ArgumentException(); } checked { TierPoints += CalculateTierCost(shortcut.Tier); TierPoints -= CalculateTierCost(tier); } shortcut.Tier = tier; saveMask |= ActionSetSaveMask.ActionSetActions; }