361 lines
16 KiB
Markdown
361 lines
16 KiB
Markdown
# Dress Manager
|
||
|
||
<cite>
|
||
**Referenced Files in This Document**
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressAgentTests.cs](file://ClassicAssist.Tests/Agents/DressAgentTests.cs)
|
||
</cite>
|
||
|
||
## Table of Contents
|
||
1. [Introduction](#introduction)
|
||
2. [Project Structure](#project-structure)
|
||
3. [Core Components](#core-components)
|
||
4. [Architecture Overview](#architecture-overview)
|
||
5. [Detailed Component Analysis](#detailed-component-analysis)
|
||
6. [Dependency Analysis](#dependency-analysis)
|
||
7. [Performance Considerations](#performance-considerations)
|
||
8. [Troubleshooting Guide](#troubleshooting-guide)
|
||
9. [Conclusion](#conclusion)
|
||
|
||
## Introduction
|
||
The Dress Manager feature enables players to create and switch between predefined outfit configurations (dress sets). Each set defines a mapping from equipment slots to specific items, with optional conditions for automatic switching. The system supports multiple item types such as Body, Head, Arms, Legs, and more, allowing tailored setups for combat, casual wear, or profession-specific tasks.
|
||
|
||
## Project Structure
|
||
The Dress Manager spans shared data models, the manager logic, UI view models, and Avalonia/WPF views:
|
||
- Shared data layer: structures and enums defining dress entries, items, and item types; the core manager orchestrating operations.
|
||
- UI layer: Avalonia and WPF tabs that present the interface for creating and managing dress sets.
|
||
- Tests: unit tests validating behavior and edge cases.
|
||
|
||
```mermaid
|
||
graph TB
|
||
subgraph "Shared Data"
|
||
Entry["DressAgentEntry"]
|
||
Item["DressAgentItem"]
|
||
ItemType["DressAgentItemType"]
|
||
Manager["DressManager"]
|
||
end
|
||
subgraph "UI - Avalonia"
|
||
VM_Ava["DressTabViewModel"]
|
||
Tab_Ava["DressTabControl.axaml.cs"]
|
||
end
|
||
subgraph "UI - WPF"
|
||
Tab_WPF["DressTabControl.xaml.cs"]
|
||
end
|
||
subgraph "Tests"
|
||
Tests["DressAgentTests.cs"]
|
||
end
|
||
VM_Ava --> Manager
|
||
Tab_Ava --> VM_Ava
|
||
Tab_WPF --> VM_Ava
|
||
Manager --> Entry
|
||
Manager --> Item
|
||
Manager --> ItemType
|
||
Tests --> Manager
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressAgentTests.cs](file://ClassicAssist.Tests/Agents/DressAgentTests.cs)
|
||
|
||
**Section sources**
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressAgentTests.cs](file://ClassicAssist.Tests/Agents/DressAgentTests.cs)
|
||
|
||
## Core Components
|
||
- DressAgentEntry: Represents a named dress set containing a list of slot-to-item mappings and optional switching conditions.
|
||
- DressAgentItem: Describes a single slot assignment within a set, including target slot and item selection criteria.
|
||
- DressAgentItemType: Enumerates supported equipment categories (e.g., Body, Head, Arms, Legs, etc.) used to map items to character slots.
|
||
- DressManager: Provides methods to add/remove/update sets, evaluate conditions, and perform equip/unequip actions across inventory and equipped layers.
|
||
|
||
Key responsibilities:
|
||
- Set management: CRUD operations on dress sets.
|
||
- Slot mapping: Associate items with specific equipment slots.
|
||
- Conditional switching: Evaluate environment or state-based rules to auto-switch sets.
|
||
- Execution: Equip/unequip items according to the active set.
|
||
|
||
**Section sources**
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
|
||
## Architecture Overview
|
||
The UI binds to a ViewModel which delegates to the DressManager. The manager reads the active set, validates items against inventory/equipment, and issues commands to apply changes. Conditions are evaluated before applying a set automatically.
|
||
|
||
```mermaid
|
||
sequenceDiagram
|
||
participant User as "User"
|
||
participant UI as "DressTabControl"
|
||
participant VM as "DressTabViewModel"
|
||
participant Mgr as "DressManager"
|
||
participant Game as "Game Engine"
|
||
User->>UI : Open Dress tab
|
||
UI->>VM : Load sets and current state
|
||
VM->>Mgr : GetSets() / GetCurrentSet()
|
||
Mgr-->>VM : Sets + Active
|
||
VM-->>UI : Bind collections
|
||
User->>UI : Select a set
|
||
UI->>VM : ApplySet(setId)
|
||
VM->>Mgr : EvaluateConditions(set)
|
||
Mgr-->>VM : CanApply?
|
||
alt Conditions met
|
||
VM->>Mgr : ApplySet(set)
|
||
Mgr->>Game : Unequip conflicting items
|
||
Mgr->>Game : Equip items per slot
|
||
Mgr-->>VM : Success/Failure
|
||
VM-->>UI : Update status
|
||
else Conditions not met
|
||
VM-->>UI : Show reason
|
||
end
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
|
||
## Detailed Component Analysis
|
||
|
||
### Data Model: DressAgentEntry, DressAgentItem, DressAgentItemType
|
||
- DressAgentEntry holds:
|
||
- A unique identifier and display name for the set.
|
||
- A collection of DressAgentItem entries describing each slot assignment.
|
||
- Optional fields for enabling/disabling the set and any metadata needed by conditions.
|
||
- DressAgentItem holds:
|
||
- Target slot type (from DressAgentItemType).
|
||
- Selection criteria for the item (e.g., by ID, properties, or other filters).
|
||
- DressAgentItemType enumerates supported equipment categories such as Body, Head, Arms, Legs, and others used by the game’s equipment layers.
|
||
|
||
```mermaid
|
||
classDiagram
|
||
class DressAgentEntry {
|
||
+string Id
|
||
+string Name
|
||
+bool Enabled
|
||
+DressAgentItem[] Items
|
||
}
|
||
class DressAgentItem {
|
||
+DressAgentItemType SlotType
|
||
+object ItemCriteria
|
||
}
|
||
class DressAgentItemType {
|
||
<<enumeration>>
|
||
+Body
|
||
+Head
|
||
+Arms
|
||
+Legs
|
||
+...
|
||
}
|
||
DressAgentEntry "1" o--> "*" DressAgentItem : "contains"
|
||
DressAgentItem --> DressAgentItemType : "uses"
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
|
||
**Section sources**
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
|
||
### Manager Logic: DressManager
|
||
Responsibilities:
|
||
- Manage the collection of dress sets and persistence.
|
||
- Determine the currently active set based on user selection or automatic conditions.
|
||
- Validate whether an item exists in inventory or can be obtained.
|
||
- Execute equip/unequip operations respecting slot conflicts and priorities.
|
||
- Provide hooks for condition evaluation to support automatic switching.
|
||
|
||
Operational flow highlights:
|
||
- Add/Set operations update internal collections and notify UI via the ViewModel.
|
||
- ApplySet performs validation, resolves items to concrete objects, and applies changes.
|
||
- Condition evaluation checks contextual factors (e.g., location, skill level, time) before auto-applying a set.
|
||
|
||
```mermaid
|
||
flowchart TD
|
||
Start(["Start ApplySet"]) --> Validate["Validate set and items"]
|
||
Validate --> Valid{"All items valid?"}
|
||
Valid -- No --> Error["Return error with details"]
|
||
Valid -- Yes --> Resolve["Resolve items to targets"]
|
||
Resolve --> Conflicts{"Conflicting equipped items?"}
|
||
Conflicts -- Yes --> Unequip["Unequip conflicting items"]
|
||
Conflicts -- No --> SkipUnequip["Skip unequip"]
|
||
Unequip --> Equip["Equip items per slot"]
|
||
SkipUnequip --> Equip
|
||
Equip --> Done(["Complete"])
|
||
Error --> Done
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
|
||
**Section sources**
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
|
||
### UI Layer: DressTabControl and DressTabViewModel
|
||
- DressTabControl (Avalonia and WPF variants): Hosts the Dress Manager UI, binds to the ViewModel, and handles user interactions like selecting sets and triggering apply actions.
|
||
- DressTabViewModel: Exposes observable collections of sets, selected set, and status messages. It calls into DressManager for operations and updates UI state accordingly.
|
||
|
||
User workflow:
|
||
- Create a new set by adding entries for desired slots.
|
||
- Configure item selection criteria for each slot.
|
||
- Optionally enable automatic switching by setting conditions.
|
||
- Apply a set manually or rely on automatic triggers.
|
||
|
||
```mermaid
|
||
sequenceDiagram
|
||
participant View as "DressTabControl"
|
||
participant VM as "DressTabViewModel"
|
||
participant Mgr as "DressManager"
|
||
View->>VM : OnCreateSet()
|
||
VM->>Mgr : CreateNewSet()
|
||
Mgr-->>VM : New set reference
|
||
VM-->>View : Refresh list
|
||
View->>VM : OnAddSlot(slotType, criteria)
|
||
VM->>Mgr : AddItemToSet(setId, item)
|
||
Mgr-->>VM : Updated set
|
||
VM-->>View : Rebind grid
|
||
View->>VM : OnApplySet(setId)
|
||
VM->>Mgr : ApplySet(setId)
|
||
Mgr-->>VM : Result
|
||
VM-->>View : Show success/failure
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
|
||
**Section sources**
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
|
||
### Item Types and Slot Mapping
|
||
Supported item types include common equipment categories such as Body, Head, Arms, Legs, and others defined by the enumeration. Each type maps to a corresponding equipment layer in the game client. When building a set, ensure the chosen item is compatible with the selected slot type.
|
||
|
||
Behavioral notes:
|
||
- Some slots may have precedence rules (e.g., headgear vs. helm).
|
||
- Certain items may require prerequisites (skills, quests) to be equippable.
|
||
- Auto-switching should consider these constraints to avoid invalid states.
|
||
|
||
**Section sources**
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
|
||
### Conditional Switching Logic
|
||
Automatic switching evaluates conditions before applying a set. Typical conditions include:
|
||
- Location or region checks.
|
||
- Skill thresholds.
|
||
- Time of day or season.
|
||
- Player state flags (e.g., mounted, in combat).
|
||
|
||
The manager exposes evaluation points so the UI can preview applicability and provide feedback when conditions are not met.
|
||
|
||
**Section sources**
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
|
||
### Examples and Use Cases
|
||
- Combat gear: Equip high-defense Body, Head, Arms, and Legs items; optionally include weapon/shield slots if supported.
|
||
- Casual wear: Lower-stat clothing for social areas or roleplay.
|
||
- Profession-specific outfits: Items optimized for crafting, mining, or fishing activities.
|
||
|
||
Tips:
|
||
- Keep sets focused on distinct scenarios to minimize conflicts.
|
||
- Use clear naming conventions for quick identification.
|
||
- Validate availability before relying on auto-switching.
|
||
|
||
[No sources needed since this section provides general guidance]
|
||
|
||
## Dependency Analysis
|
||
The following diagram shows how components depend on each other:
|
||
|
||
```mermaid
|
||
graph LR
|
||
VM["DressTabViewModel"] --> Mgr["DressManager"]
|
||
TabAva["DressTabControl.axaml.cs"] --> VM
|
||
TabWpf["DressTabControl.xaml.cs"] --> VM
|
||
Mgr --> Entry["DressAgentEntry"]
|
||
Mgr --> Item["DressAgentItem"]
|
||
Mgr --> Type["DressAgentItemType"]
|
||
Tests["DressAgentTests.cs"] --> Mgr
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
- [DressAgentTests.cs](file://ClassicAssist.Tests/Agents/DressAgentTests.cs)
|
||
|
||
**Section sources**
|
||
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
|
||
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
|
||
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
|
||
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
|
||
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
|
||
- [DressAgentTests.cs](file://ClassicAssist.Tests/Agents/DressAgentTests.cs)
|
||
|
||
## Performance Considerations
|
||
- Minimize repeated evaluations of conditions by caching results where appropriate.
|
||
- Batch equip/unequip operations to reduce network overhead.
|
||
- Avoid heavy item resolution during UI rendering; defer to background threads if necessary.
|
||
- Prefer precise item selection criteria to reduce search space.
|
||
|
||
[No sources needed since this section provides general guidance]
|
||
|
||
## Troubleshooting Guide
|
||
Common issues and resolutions:
|
||
- Missing or unavailable equipment:
|
||
- Ensure required items exist in your backpack or on the character.
|
||
- Verify item compatibility with the selected slot type.
|
||
- Check prerequisites such as skills or quest requirements.
|
||
- Automatic switching not triggering:
|
||
- Review condition definitions for correctness and completeness.
|
||
- Confirm that the environment/state matches expected values.
|
||
- Conflicting equipped items:
|
||
- Remove or replace conflicting items before applying a set.
|
||
- Adjust set composition to avoid overlapping slots.
|
||
- UI not reflecting changes:
|
||
- Refresh the view model bindings after applying a set.
|
||
- Inspect status messages returned by the manager for errors.
|
||
|
||
Validation tips:
|
||
- Test sets in safe zones first.
|
||
- Use manual application before enabling auto-switching.
|
||
- Keep backups of critical sets.
|
||
|
||
**Section sources**
|
||
- [DressAgentTests.cs](file://ClassicAssist.Tests/Agents/DressAgentTests.cs)
|
||
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
|
||
|
||
## Conclusion
|
||
The Dress Manager provides a robust system for organizing and automating outfit changes through well-defined data structures and a clear separation between UI and logic. By leveraging slot mappings, item types, and conditional switching, players can streamline transitions between combat, casual, and profession-specific gear while maintaining control over inventory requirements and validation.
|
||
|
||
[No sources needed since this section summarizes without analyzing specific files] |