first commit

This commit is contained in:
Beyhan Oğur
2026-09-03 04:45:36 +03:00
commit d5f52cc3d3
1038 changed files with 169579 additions and 0 deletions
@@ -0,0 +1,377 @@
# Advanced Features and Customization
<cite>
**Referenced Files in This Document**
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [AutolootTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.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)
10. [Appendices](#appendices)
## Introduction
This document explains advanced autoloot features and customization options with a focus on the AutolootViewModel’s role in managing rule collections and providing MVVM binding for the UI. It covers advanced filtering capabilities (including regular expressions, custom property evaluators, and conditional logic based on player state or location), performance tuning for high-throughput scenarios, memory management for large rule sets, extension points for creating custom property types and operators, debugging techniques for complex rule conflicts, monitoring autoloot performance metrics, and strategies for organizing and maintaining large collections across different gameplay scenarios.
## Project Structure
The autoloot feature spans shared data models, managers, view models, UI views, and tests:
- Shared data layer defines rule entries, constraints, properties, operators, and the manager orchestrating evaluation.
- View model binds rules to UI and exposes commands and observable collections.
- Avalonia/XAML views provide configuration windows and tabs for editing rules.
- Tests validate behavior and edge cases.
```mermaid
graph TB
subgraph "Shared Data"
AM["AutolootManager"]
AE["AutolootEntry"]
ACE["AutolootConstraintEntry"]
PE["PropertyEntry"]
PT["PropertyType"]
AO["AutolootOperator"]
end
subgraph "UI Layer"
VM["AutolootViewModel"]
TAB["AutolootTabControl"]
CPW["CustomPropertiesWindow"]
PSW["PropertySelectionWindow"]
CLW["ClilocSelectionWindow"]
end
subgraph "Tests"
T["AutolootTests"]
end
VM --> AM
AM --> AE
AE --> ACE
AE --> PE
PE --> PT
AE --> AO
TAB --> VM
CPW --> VM
PSW --> VM
CLW --> VM
T --> AM
```
**Diagram sources**
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [AutolootTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.cs)
**Section sources**
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [AutolootTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.cs)
## Core Components
- AutolootViewModel: Manages rule collections, provides MVVM bindings for the UI, and coordinates rule evaluation requests from the UI.
- AutolootManager: Central engine that evaluates rules against game objects using configured properties, operators, and constraints.
- AutolootEntry: Represents an individual autoloot rule with associated conditions and actions.
- AutolootConstraintEntry: Encapsulates constraint definitions used by rules.
- PropertyEntry and PropertyType: Define available properties and their types for rule conditions.
- AutolootOperator: Defines supported operators for evaluating conditions.
- UI Views: Provide dialogs and controls for selecting properties, clilocs, and configuring custom properties.
Key responsibilities:
- Rule collection lifecycle (add, remove, reorder, import/export).
- Binding observable collections to UI elements.
- Invoking evaluation pipelines when items drop or are picked up.
- Exposing validation and error feedback to users.
**Section sources**
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
## Architecture Overview
The autoloot system follows an MVVM pattern:
- The ViewModel owns rule collections and exposes them to XAML views.
- The Manager performs rule evaluation using data models and operators.
- UI components trigger evaluations and display results or errors.
```mermaid
sequenceDiagram
participant UI as "AutolootTabControl"
participant VM as "AutolootViewModel"
participant M as "AutolootManager"
participant E as "AutolootEntry"
participant C as "AutolootConstraintEntry"
participant P as "PropertyEntry"
participant O as "AutolootOperator"
UI->>VM : "User edits rule or triggers evaluation"
VM->>M : "Evaluate(item, rules)"
M->>E : "Iterate rules"
E->>C : "Check constraints"
C->>P : "Resolve property value"
P->>O : "Apply operator"
O-->>C : "Boolean result"
C-->>E : "Aggregate condition(s)"
E-->>M : "Match decision"
M-->>VM : "Result + diagnostics"
VM-->>UI : "Update UI / notify user"
```
**Diagram sources**
- [AutolootTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
## Detailed Component Analysis
### AutolootViewModel: Rule Collection Management and MVVM Binding
Responsibilities:
- Maintain observable collections of rules and related metadata.
- Provide commands for adding, removing, duplicating, and reordering rules.
- Bind rule properties to UI controls via data templates and converters.
- Coordinate with AutolootManager to evaluate rules and present outcomes.
- Expose validation messages and error states to the UI.
MVVM patterns:
- Observable collections for two-way binding.
- Commands encapsulating user actions.
- Properties raising change notifications for reactive UI updates.
Common usage:
- Initialize rule set from configuration or defaults.
- Handle item pickup/drop events by invoking evaluation through the manager.
- Persist changes back to storage.
**Section sources**
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
### AutolootManager: Evaluation Engine
Responsibilities:
- Iterate over rule entries and apply constraints.
- Resolve property values and apply operators to compute boolean conditions.
- Aggregate multiple constraints per rule and determine matches.
- Return match results and optional diagnostic information for debugging.
Evaluation flow:
- For each incoming object, iterate rules in priority order.
- For each rule, evaluate all constraints; short-circuit on first failure if applicable.
- Use property resolution and operator application to decide matches.
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
### Rule Models: AutolootEntry, AutolootConstraintEntry, PropertyEntry, PropertyType, AutolootOperator
- AutolootEntry: Holds rule-level settings, constraints, and actions.
- AutolootConstraintEntry: Defines a single condition with left/right operands and operator.
- PropertyEntry: Describes a resolvable property path and its type.
- PropertyType: Enumerates supported property types for conversion and comparison.
- AutolootOperator: Enumerates supported operators (e.g., equals, contains, regex).
These models enable declarative rule definition and flexible evaluation.
**Section sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
### UI Integration: Tabs and Windows
- AutolootTabControl: Hosts the autoloot UI within the agents tabbed interface.
- CustomPropertiesWindow: Allows defining or editing custom properties for advanced scenarios.
- PropertySelectionWindow: Provides a guided selection of available properties for rule conditions.
- ClilocSelectionWindow: Enables selecting localized strings for rule matching.
These views bind to AutolootViewModel and delegate evaluation to the manager.
**Section sources**
- [AutolootTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
### Testing and Validation
- AutolootTests: Contains unit/integration tests validating rule evaluation, constraints, and edge cases.
Use these tests as references for expected behaviors and to guide customizations.
**Section sources**
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.cs)
## Dependency Analysis
The following diagram shows key dependencies among core autoloot components:
```mermaid
classDiagram
class AutolootViewModel {
+Rules
+AddRule()
+RemoveRule()
+Evaluate(item)
}
class AutolootManager {
+Evaluate(item, rules)
-ResolveProperty(entry)
-ApplyOperator(op, left, right)
}
class AutolootEntry {
+Constraints
+Actions
}
class AutolootConstraintEntry {
+LeftOperand
+RightOperand
+Operator
}
class PropertyEntry {
+Path
+Type
}
class PropertyType {
}
class AutolootOperator {
}
AutolootViewModel --> AutolootManager : "uses"
AutolootManager --> AutolootEntry : "iterates"
AutolootEntry --> AutolootConstraintEntry : "contains"
AutolootConstraintEntry --> PropertyEntry : "references"
PropertyEntry --> PropertyType : "typed"
AutolootConstraintEntry --> AutolootOperator : "applies"
```
**Diagram sources**
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
**Section sources**
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
## Performance Considerations
High-throughput scenarios benefit from careful rule design and evaluation optimization:
- Rule ordering: Place most selective rules earlier to short-circuit evaluation quickly.
- Constraint composition: Prefer exact matches before broad patterns; use negation sparingly.
- Operator selection: Choose operators that minimize string processing overhead where possible.
- Property resolution caching: Avoid repeated expensive lookups by leveraging cached property values when available.
- Batch evaluation: When many items arrive simultaneously, consider batching to reduce per-item overhead.
- Memory management: Limit rule set size by splitting into scenario-specific profiles; unload unused rules at runtime if supported.
- Diagnostics: Enable lightweight logging only during troubleshooting to avoid overhead in production.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Debugging complex rule conflicts:
- Inspect rule priority and order; conflicting rules may be overridden by higher-priority entries.
- Validate constraint operands and operators; ensure property paths resolve correctly for the target object.
- Use test cases to reproduce issues deterministically; compare expected vs actual outcomes.
- Narrow down by disabling subsets of rules to isolate problematic conditions.
- Review UI feedback and error messages exposed by the ViewModel for invalid configurations.
Monitoring autoloot performance metrics:
- Track evaluation time per rule and overall throughput during peak activity.
- Log counts of matched vs skipped rules to identify bottlenecks.
- Monitor memory usage growth when loading large rule sets; consider profile-based loading.
**Section sources**
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
## Conclusion
The autoloot subsystem combines a robust MVVM architecture with flexible rule modeling and evaluation. By leveraging advanced filtering, custom properties, and operators, users can create precise and performant autoloot behaviors. Organizing rules into focused profiles, applying performance best practices, and using testing and diagnostics ensures maintainability and reliability across diverse gameplay scenarios.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
### Advanced Filtering Capabilities
- Regular expression support: Use regex-capable operators for pattern matching on names, descriptions, or other text properties.
- Custom property evaluators: Extend PropertyEntry and PropertyType to introduce new resolvable attributes.
- Conditional logic: Combine multiple constraints with logical operators to implement complex conditions based on player state or location.
Implementation pointers:
- Add new operators to AutolootOperator and integrate evaluation logic in the manager.
- Register custom properties via PropertyEntry and ensure proper type handling with PropertyType.
- Compose constraints in AutolootConstraintEntry to express multi-condition logic.
**Section sources**
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
### Creating Custom Property Types and Operators
Steps:
- Define a new PropertyType and corresponding PropertyEntry to expose the property path.
- Implement operator logic in AutolootOperator and update evaluation routines accordingly.
- Wire UI components (PropertySelectionWindow, CustomPropertiesWindow) to allow users to select and configure the new property/operator.
Validation:
- Add tests covering edge cases and performance characteristics.
- Ensure backward compatibility with existing rules.
**Section sources**
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/UI/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.cs)
### Organizing and Maintaining Large Rule Collections
Strategies:
- Group rules by gameplay scenario (e.g., farming, questing, PvP) and load relevant profiles dynamically.
- Use consistent naming conventions and comments in rule metadata for clarity.
- Periodically review and prune unused or redundant rules.
- Employ version control to track changes and collaborate effectively.
[No sources needed since this section provides general guidance]
@@ -0,0 +1,437 @@
# Autoloot System
<cite>
**Referenced Files in This Document**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [ClilocSelectionViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/ClilocSelectionViewModel.cs)
- [PropertySelectionViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/PropertySelectionViewModel.cs)
- [CustomPropertiesViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/CustomPropertiesViewModel.cs)
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.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)
10. [Appendices](#appendices)
## Introduction
The Autoloot system is a rule-based item collection engine that automatically picks up items based on configurable criteria. It allows players to define rules that match items by properties such as name, hue, weight, and more. Each rule consists of one or more constraints evaluated with logical operators (AND/OR). The UI provides intuitive windows for selecting cliloc names and properties, enabling users to build complex filters without writing code.
This document explains the data model, constraint matching engine, operator types, property filtering, UI components, practical scenarios, performance optimization techniques, and debugging strategies for autoloot rules.
## Project Structure
The Autoloot system spans shared data models, managers, UI view models, and Avalonia/WPF views:
- Shared data layer:
- Rule entry and constraint definitions
- Operator enumeration and helper utilities
- Property metadata and type mapping
- Manager and helpers:
- Rule evaluation and integration with game objects
- UI layer:
- ViewModels for managing rules and selection dialogs
- Avalonia and WPF views for user interaction
```mermaid
graph TB
subgraph "Shared Data"
A["AutolootEntry"]
B["AutolootConstraintEntry"]
C["AutolootOperator"]
D["PropertyEntry"]
E["PropertyType"]
F["AutolootManager"]
G["AutolootHelpers"]
end
subgraph "UI Layer"
H["AutolootViewModel"]
I["ClilocSelectionViewModel"]
J["PropertySelectionViewModel"]
K["CustomPropertiesViewModel"]
L["AutolootTabControl (Avalonia)"]
M["ClilocSelectionWindow (WPF)"]
N["PropertySelectionWindow (WPF)"]
O["CustomPropertiesWindow (WPF)"]
end
subgraph "Game Objects"
P["Item"]
Q["EntityCollection"]
end
A --> B
B --> C
A --> D
D --> E
F --> A
F --> B
F --> C
F --> G
F --> P
F --> Q
H --> A
H --> F
I --> M
J --> N
K --> O
L --> H
```
**Diagram sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [ClilocSelectionViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/ClilocSelectionViewModel.cs)
- [PropertySelectionViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/PropertySelectionViewModel.cs)
- [CustomPropertiesViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/CustomPropertiesViewModel.cs)
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
**Section sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [ClilocSelectionViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/ClilocSelectionViewModel.cs)
- [PropertySelectionViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/PropertySelectionViewModel.cs)
- [CustomPropertiesViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Autoloot/CustomPropertiesViewModel.cs)
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
## Core Components
- AutolootEntry: Represents a single autoloot rule with a list of constraints and an overall logical combination strategy.
- AutolootConstraintEntry: Defines a single condition consisting of a target property, an operator, and a value.
- AutolootOperator: Enumerates supported comparison operators (e.g., Equals, Contains, GreaterThan, LessThan, NotEquals, StartsWith, EndsWith).
- PropertyEntry and PropertyType: Provide metadata about available item properties and their types for safe comparisons.
- AutolootManager: Orchestrates rule evaluation against the current item pool and triggers pick-up actions when rules match.
- AutolootHelpers: Utility functions for parsing, normalization, and common operations used during constraint evaluation.
Key responsibilities:
- Constraint matching: Evaluate each constraint against an Item’s properties using the specified operator and value.
- Logical composition: Combine multiple constraints within a rule using AND/OR logic.
- Integration: Connect with the game object model (Item) and collections (EntityCollection) to scan and act on items.
**Section sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
## Architecture Overview
The Autoloot system follows a layered architecture:
- Data layer: Models and enumerations define the structure of rules and constraints.
- Engine layer: Manager evaluates rules against live game objects and performs actions.
- UI layer: ViewModels and Views provide configuration interfaces for creating and editing rules.
```mermaid
sequenceDiagram
participant User as "User"
participant Tab as "AutolootTabControl"
participant VM as "AutolootViewModel"
participant Manager as "AutolootManager"
participant Pool as "EntityCollection"
participant Item as "Item"
User->>Tab : Open Autoloot tab
Tab->>VM : Initialize ViewModel
VM->>Manager : Load rules and settings
loop For each new item
Pool->>Manager : Notify item added
Manager->>Pool : Iterate visible items
Manager->>Item : Read properties
Manager->>Manager : Evaluate constraints per rule
alt Rule matches
Manager-->>User : Pick up item
else No match
Manager-->>Pool : Continue scanning
end
end
```
**Diagram sources**
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
## Detailed Component Analysis
### AutolootEntry and Constraint Matching
AutolootEntry encapsulates a rule composed of multiple AutolootConstraintEntry instances. Each constraint specifies:
- Target property (from PropertyEntry)
- Operator (from AutolootOperator)
- Value to compare against
Logical combination:
- Rules can combine constraints using AND/OR semantics.
- When all constraints are satisfied under the chosen combination, the rule matches.
Evaluation flow:
- For each Item, read relevant properties.
- Apply operator-specific comparison logic.
- Aggregate results according to the rule’s logical combination.
```mermaid
flowchart TD
Start(["Start Evaluation"]) --> GetRule["Get AutolootEntry"]
GetRule --> InitResult["Initialize result based on combination (AND/OR)"]
InitResult --> LoopConstraints{"For each constraint"}
LoopConstraints --> |Next| ReadProp["Read Item property"]
ReadProp --> Compare["Apply operator vs value"]
Compare --> UpdateResult["Update aggregate result"]
UpdateResult --> LoopConstraints
LoopConstraints --> |Done| FinalCheck{"Final result true?"}
FinalCheck --> |Yes| Match["Rule matches"]
FinalCheck --> |No| NoMatch["Rule does not match"]
Match --> End(["End"])
NoMatch --> End
```
**Diagram sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
**Section sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
### Operators and Property Filtering
Supported operators include:
- Equals: Exact match
- NotEquals: Inverse exact match
- Contains: Substring presence
- StartsWith: Prefix match
- EndsWith: Suffix match
- GreaterThan: Numeric greater than
- LessThan: Numeric less than
- GreaterThanOrEqual: Numeric greater than or equal
- LessThanOrEqual: Numeric less than or equal
Property filtering capabilities:
- PropertyEntry defines available properties and their types (PropertyType).
- Type-aware comparisons ensure correct handling of strings, numbers, booleans, and enums.
- Helpers normalize values (e.g., trimming, case-insensitive comparisons where appropriate).
Practical examples:
- Gold collection: Match items by name containing “Gold” and weight equals zero.
- Material gathering: Match items by category or name patterns and exclude low-value variants.
- Equipment filtering: Match by slot, quality thresholds, and specific hues.
**Section sources**
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
### UI Components: ClilocSelectionWindow and PropertySelectionWindow
The UI enables users to create and manage autoloot rules through dedicated windows and tabs:
- ClilocSelectionWindow: Allows selecting localized text entries (clilocs) to match item names or descriptions.
- PropertySelectionWindow: Provides a structured interface to choose properties and set constraints.
- CustomPropertiesWindow: Enables advanced property configuration and custom filters.
- AutolootTabControl (Avalonia): Hosts the main autoloot management interface and integrates with ViewModels.
Workflow:
- Users open the Autoloot tab and add/edit rules.
- They use ClilocSelectionWindow to pick cliloc-based name filters.
- They use PropertySelectionWindow to select properties and operators.
- Changes propagate via ViewModels to the manager for evaluation.
```mermaid
classDiagram
class AutolootTabControl {
+Initialize()
+LoadRules()
+SaveRules()
}
class AutolootViewModel {
+Rules
+AddRule()
+RemoveRule()
+EvaluateAll()
}
class ClilocSelectionWindow {
+ShowDialog()
+SelectedClilocs
}
class PropertySelectionWindow {
+ShowDialog()
+SelectedProperties
}
class CustomPropertiesWindow {
+ShowDialog()
+CustomFilters
}
AutolootTabControl --> AutolootViewModel : "uses"
AutolootViewModel --> ClilocSelectionWindow : "opens"
AutolootViewModel --> PropertySelectionWindow : "opens"
AutolootViewModel --> CustomPropertiesWindow : "opens"
```
**Diagram sources**
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
**Section sources**
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
- [ClilocSelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/ClilocSelectionWindow.xaml.cs)
- [PropertySelectionWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/PropertySelectionWindow.xaml.cs)
- [CustomPropertiesWindow.xaml.cs](file://ClassicAssist/Views/Autoloot/CustomPropertiesWindow.xaml.cs)
### Practical Scenarios
- Gold Collection:
- Create a rule with a constraint on item name containing “Gold”.
- Add a weight equals zero constraint to avoid heavy stacks.
- Use OR to allow multiple gold variants if needed.
- Material Gathering:
- Define constraints for material categories using property filters.
- Exclude unwanted hues or qualities using NotEquals and LessThan operators.
- Equipment Filtering:
- Match by slot and quality thresholds.
- Use StartsWith/EndsWith for naming conventions.
- Combine constraints with AND to narrow down precise matches.
[No sources needed since this section provides general guidance]
## Dependency Analysis
The Autoloot system has clear separation between data models, evaluation logic, and UI components. Key dependencies:
- AutolootManager depends on:
- AutolootEntry and AutolootConstraintEntry for rule structures
- AutolootOperator for comparison logic
- PropertyEntry and PropertyType for property metadata
- Item and EntityCollection for scanning and acting on game objects
- UI components depend on:
- AutolootViewModel for state and actions
- Selection windows for user input
```mermaid
graph LR
Manager["AutolootManager"] --> Entry["AutolootEntry"]
Manager --> Constraint["AutolootConstraintEntry"]
Manager --> Operator["AutolootOperator"]
Manager --> PropEntry["PropertyEntry"]
Manager --> PropType["PropertyType"]
Manager --> ItemObj["Item"]
Manager --> Pool["EntityCollection"]
Tab["AutolootTabControl"] --> VM["AutolootViewModel"]
VM --> Manager
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [AutolootTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.axaml.cs)
- [AutolootViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/AutolootViewModel.cs)
## Performance Considerations
Optimization techniques for large item pools:
- Early exit: Short-circuit constraint evaluation when a rule fails early (especially with AND combinations).
- Property caching: Cache frequently accessed properties to reduce repeated reads.
- Batch scanning: Process items in batches to minimize overhead and improve throughput.
- Indexing: Maintain lightweight indexes for commonly filtered properties (e.g., hue, weight).
- Avoid expensive operations: Prefer substring checks only when necessary; use prefix/suffix operators for faster matching.
- Throttling: Limit evaluation frequency to avoid excessive CPU usage during high packet rates.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and debugging strategies:
- Rule conflicts:
- Multiple rules may match the same item; review logical combinations and precedence.
- Use logging to trace which rules matched and why.
- Incorrect property values:
- Verify PropertyType alignment with operator usage (e.g., numeric operators on string properties).
- Normalize inputs (trimming, case-insensitivity) to prevent false negatives.
- Performance bottlenecks:
- Monitor evaluation time per rule; simplify constraints or reduce rule count.
- Profile item pool size and adjust scanning intervals.
- UI misconfiguration:
- Ensure selected clilocs and properties exist and are valid.
- Reopen selection windows to refresh available options.
Use tests to validate behavior:
- AutolootTests cover typical scenarios and edge cases.
**Section sources**
- [AutolootTests.cs](file://ClassicAssist.Tests/Agents/AutolootTests.cs)
## Conclusion
The Autoloot system provides a flexible, rule-based approach to automatic item collection. By combining property filtering, operator support, and logical composition, it accommodates diverse gameplay needs—from simple gold pickup to sophisticated equipment filtering. The UI components streamline rule creation, while the manager ensures efficient evaluation against the active item pool. With careful design and performance optimizations, the system scales well even with large item counts.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
- Additional references:
- AutolootViewModel for rule lifecycle management
- AutolootHelpers for utility functions used across evaluation
- PropertyEntry and PropertyType for comprehensive property metadata
[No sources needed since this section provides general guidance]
@@ -0,0 +1,392 @@
# Core Concepts and Architecture
<cite>
**Referenced Files in This Document**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [SAWorldItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/SAWorldItem.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.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
This document explains the core concepts and architecture of the Autoloot system, focusing on automatic item collection. It details how rules are defined and evaluated, how the manager orchestrates detection and pickup, and how helper utilities support matching and validation. The goal is to provide a clear mental model for both new contributors and users who want to understand or extend autoloot behavior.
## Project Structure
The Autoloot feature resides primarily under the shared data layer and integrates with the UO networking and object models:
- Data definitions and logic: ClassicAssist.Shared/Data/Autoloot
- Game objects and collections: ClassicAssist.Shared/UO/Objects
- Network packets and handlers: ClassicAssist.Shared/UO/Network
```mermaid
graph TB
subgraph "Shared Data"
A["AutolootEntry"]
B["AutolootManager"]
C["AutolootHelpers"]
D["AutolootConstraintEntry"]
E["AutolootOperator"]
F["PropertyEntry"]
G["PropertyType"]
end
subgraph "UO Objects"
H["Item"]
I["EntityCollection"]
J["ItemCollection"]
end
subgraph "UO Network"
K["IncomingPacketHandlers"]
L["ContainerContentsPacket"]
M["DropItem"]
N["SAWorldItem"]
end
B --> A
B --> C
B --> H
B --> I
B --> J
C --> D
C --> E
C --> F
C --> G
K --> L
K --> M
K --> N
K --> B
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [SAWorldItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/SAWorldItem.cs)
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
## Core Components
- AutolootEntry: Represents a single autoloot rule. It defines what items match (e.g., by name, hue, properties), constraints, and actions such as pickup. Its lifecycle spans creation, configuration, evaluation against game items, and execution of pickup commands when matched.
- AutolootManager: Orchestrates the autoloot pipeline. It listens for incoming world/container updates, enumerates candidate items, evaluates them against configured rules, and executes pickup actions. It also manages rule persistence and runtime state.
- AutolootHelpers: Provides common operations used across autoloot logic, including item matching helpers, property-based comparisons, and validation utilities. These reduce duplication and centralize complex checks.
- Supporting types:
- AutolootConstraintEntry: Encapsulates individual constraint conditions within a rule.
- AutolootOperator: Enumerates supported operators for comparisons (e.g., equals, contains).
- PropertyEntry and PropertyType: Model property keys and their types for property-based matching.
These components collaborate to transform raw network events into deterministic, configurable item pickups.
**Section sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
## Architecture Overview
The autoloot pipeline follows a consistent flow from packet reception to item pickup:
1. Incoming packets indicate new or updated items (world drops, container contents).
2. Handlers extract item references and notify the manager.
3. The manager filters candidates and evaluates each against active rules.
4. For matches, the manager issues pickup commands through the targeting subsystem.
```mermaid
sequenceDiagram
participant Net as "IncomingPacketHandlers"
participant ItemPkt as "ContainerContentsPacket / DropItem / SAWorldItem"
participant Items as "ItemCollection / EntityCollection"
participant Manager as "AutolootManager"
participant Rule as "AutolootEntry"
participant Helpers as "AutolootHelpers"
participant Target as "Targeting System"
Net->>ItemPkt : "Parse incoming packet"
ItemPkt-->>Items : "Update/Add Item(s)"
Net->>Manager : "Notify item update/drop"
Manager->>Items : "Enumerate candidate items"
loop For each candidate
Manager->>Rule : "Evaluate rule"
Rule->>Helpers : "Match name/hue/properties"
Helpers-->>Rule : "Match result"
Rule-->>Manager : "Matched?"
end
alt Matched
Manager->>Target : "Pickup command"
Target-->>Manager : "Execution status"
else Not matched
Manager-->>Net : "No action"
end
```
**Diagram sources**
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [SAWorldItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/SAWorldItem.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
## Detailed Component Analysis
### AutolootEntry: Rule Definition and Lifecycle
AutolootEntry encapsulates a complete autoloot rule. Key responsibilities include:
- Defining match criteria: name patterns, hues, property filters, and constraints.
- Storing operator and value bindings for flexible comparisons.
- Exposing an evaluation method that returns whether a given item satisfies the rule.
- Coordinating with the manager to execute pickup actions upon a successful match.
Lifecycle highlights:
- Creation: Rules are created via UI or configuration and persisted.
- Evaluation: During processing, each candidate item is tested against all active rules.
- Execution: On match, the manager triggers pickup; otherwise, the item is ignored.
```mermaid
classDiagram
class AutolootEntry {
+string Name
+bool Enabled
+AutolootConstraintEntry[] Constraints
+bool Evaluate(Item)
+void ExecutePickup(Item)
}
class AutolootConstraintEntry {
+PropertyEntry Property
+AutolootOperator Operator
+object Value
+bool Check(Item)
}
class AutolootOperator {
<<enumeration>>
}
class PropertyEntry {
+PropertyType Type
+string Key
}
class PropertyType {
<<enumeration>>
}
AutolootEntry --> AutolootConstraintEntry : "contains"
AutolootConstraintEntry --> PropertyEntry : "uses"
PropertyEntry --> PropertyType : "typed"
```
**Diagram sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
**Section sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
### AutolootManager: Orchestration and Pipeline Control
AutolootManager coordinates the entire autoloot workflow:
- Subscribes to item-related network events and collection updates.
- Maintains the registry of active rules.
- Iterates over candidate items (ground items, container contents).
- Evaluates each item against rules using helper utilities.
- Issues pickup commands for matched items while avoiding conflicts or duplicates.
Key behaviors:
- Event-driven updates: reacts to world and container changes.
- Rule prioritization: processes rules in a deterministic order.
- Safety checks: prevents repeated pickups and respects game constraints.
```mermaid
flowchart TD
Start(["Start"]) --> Receive["Receive item update event"]
Receive --> Candidates["Collect candidate items"]
Candidates --> Loop{"For each candidate"}
Loop --> |Yes| Eval["Evaluate active rules"]
Eval --> Matched{"Any rule matched?"}
Matched --> |Yes| Pickup["Execute pickup command"]
Matched --> |No| Next["Next candidate"]
Pickup --> Next
Next --> Loop
Loop --> |No| End(["End"])
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
### AutolootHelpers: Matching and Validation Utilities
AutolootHelpers centralizes common operations used during rule evaluation:
- Name matching: supports substring and pattern checks against item names.
- Hue comparison: validates hue ranges or exact matches.
- Property evaluation: reads item properties and compares values based on type and operator.
- Constraint resolution: applies multiple constraints with logical combinations.
These helpers ensure consistent matching semantics and simplify rule implementation.
```mermaid
flowchart TD
HStart(["Helper Entry"]) --> Parse["Parse constraint"]
Parse --> TypeCheck{"Property type known?"}
TypeCheck --> |No| Fail["Return false"]
TypeCheck --> |Yes| Compare["Compare value using operator"]
Compare --> Result{"Comparison true?"}
Result --> |Yes| Pass["Return true"]
Result --> |No| Fail
```
**Diagram sources**
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
**Section sources**
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
### Conceptual Overview
At a high level, autoloot transforms network signals into user-defined actions:
- Detection: Packets reveal items appearing on the ground or inside containers.
- Filtering: Only items relevant to active rules proceed further.
- Decision: Rules evaluate properties and constraints to decide if an item should be picked up.
- Action: The manager sends targeted pickup commands to the game client.
```mermaid
graph TB
P["Packets"] --> D["Detection Layer"]
D --> F["Filtering Layer"]
F --> R["Rule Engine"]
R --> A["Action Executor"]
A --> G["Game Client"]
```
[No sources needed since this diagram shows conceptual workflow, not actual code structure]
## Dependency Analysis
The following diagram maps key dependencies among Autoloot components and their integration points with the UO engine:
```mermaid
graph LR
Manager["AutolootManager"] --> Entry["AutolootEntry"]
Manager --> Helpers["AutolootHelpers"]
Entry --> Constraint["AutolootConstraintEntry"]
Constraint --> Operator["AutolootOperator"]
Constraint --> PropEntry["PropertyEntry"]
PropEntry --> PropType["PropertyType"]
Manager --> Item["Item"]
Manager --> ItemColl["ItemCollection"]
Manager --> EntityColl["EntityCollection"]
Handler["IncomingPacketHandlers"] --> Manager
Handler --> ContPkt["ContainerContentsPacket"]
Handler --> DropPkt["DropItem"]
Handler --> WorldPkt["SAWorldItem"]
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [SAWorldItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/SAWorldItem.cs)
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
## Performance Considerations
When processing large numbers of items on the ground, consider:
- Minimize enumeration scope: Prefer filtering by region or proximity before evaluating rules.
- Short-circuit evaluation: Order rules by specificity and frequency to fail fast on non-matches.
- Avoid redundant work: Cache expensive computations (e.g., parsed patterns) and reuse results.
- Batch operations: Group pickup commands where possible to reduce overhead.
- Throttle updates: Coalesce rapid item updates to avoid thrashing the evaluation loop.
- Use efficient matching: Prefer direct property lookups and simple operators when feasible.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and diagnostics:
- No items being picked up:
- Verify rules are enabled and constraints are correctly specified.
- Confirm that incoming packet handlers are wired and updating item collections.
- Incorrect matches:
- Inspect property types and operators used in constraints.
- Validate name and hue matching logic via helper functions.
- Performance degradation:
- Reduce rule count or complexity.
- Narrow candidate sets before evaluation.
- Conflicts or missed pickups:
- Ensure unique rule priorities and avoid overlapping conditions.
- Check for duplicate handling or race conditions in event notifications.
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
## Conclusion
The Autoloot system combines well-defined rule structures with a robust orchestration layer to automate item collection. By leveraging helper utilities for matching and validation, it remains flexible and maintainable. Properly tuned, it scales to handle dense item environments while preserving responsiveness and accuracy.
@@ -0,0 +1,336 @@
# Property Matching and Filtering
<cite>
**Referenced Files in This Document**
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.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
This document explains the property matching and filtering system used by the autoloot engine. It focuses on how item attributes are represented, how rules evaluate properties against items, and how the system integrates with the UO objects layer (Item and Property). It also provides examples of complex filtering scenarios and discusses performance optimization techniques such as caching strategies for frequently accessed item properties.
## Project Structure
The autoloot feature is implemented under ClassicAssist.Shared/Data/Autoloot and integrates with the UO object model under ClassicAssist.Shared/UO/Objects. The key files include:
- Property definitions and operators
- Rule entries and constraints
- Manager and helpers for evaluation
- UO Item and Property abstractions
```mermaid
graph TB
subgraph "Autoloot Core"
PT["PropertyType.cs"]
AO["AutolootOperator.cs"]
PE["PropertyEntry.cs"]
ACE["AutolootConstraintEntry.cs"]
AE["AutolootEntry.cs"]
AM["AutolootManager.cs"]
AH["AutolootHelpers.cs"]
end
subgraph "UO Objects Layer"
ITM["Item.cs"]
PROP["Property.cs"]
end
AM --> AE
AM --> ACE
AM --> AH
AE --> ACE
ACE --> PE
PE --> PT
PE --> AO
AH --> ITM
AH --> PROP
```
**Diagram sources**
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
**Section sources**
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
## Core Components
- PropertyType defines the set of item attributes that can be matched (for example, Name, Hue, Weight, Value, etc.). These types determine which data is read from an Item and how it is compared.
- AutolootOperator enumerates comparison operations (such as equals, not equals, greater than, less than, contains, starts with, ends with, regex match, etc.) and specifies which PropertyTypes they apply to.
- PropertyEntry encapsulates a single rule condition: a PropertyType, an AutolootOperator, and a target value.
- AutolootConstraintEntry groups multiple PropertyEntry conditions into a logical constraint (typically AND semantics), representing one complete filter rule.
- AutolootEntry represents a full autoloot rule, including its name, enabled state, and a collection of constraints.
- AutolootManager orchestrates evaluation: it iterates over available items, applies each AutolootEntry’s constraints, and decides whether to collect or ignore an item.
- AutolootHelpers provides utility methods for reading and normalizing item properties, performing comparisons, and integrating with the UO Item and Property classes.
These components work together to allow expressive, high-performance filtering of items based on their dynamic properties.
**Section sources**
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
## Architecture Overview
The autoloot evaluation pipeline reads item metadata via the UO Item abstraction, resolves requested properties through Property instances, evaluates constraints using configured operators, and returns a boolean decision per rule.
```mermaid
sequenceDiagram
participant Engine as "AutolootManager"
participant Rule as "AutolootEntry"
participant Constraint as "AutolootConstraintEntry"
participant Cond as "PropertyEntry"
participant Helpers as "AutolootHelpers"
participant Item as "Item"
participant Prop as "Property"
Engine->>Rule : Iterate rules
Rule->>Constraint : For each constraint
Constraint->>Cond : For each condition
Cond->>Helpers : Evaluate(PropertyType, Operator, Target)
Helpers->>Item : Read raw property values
Item-->>Prop : Provide property accessors
Helpers->>Helpers : Normalize and compare values
Helpers-->>Cond : Boolean result
Cond-->>Constraint : Aggregate results (AND)
Constraint-->>Rule : All constraints satisfied?
Rule-->>Engine : Matched or not
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
## Detailed Component Analysis
### PropertyType: Available Item Attributes
PropertyType enumerates the supported attributes that can be referenced in autoloot rules. Typical categories include:
- Identification: Name, Serial, ItemID
- Appearance: Hue, ArtID
- Physical characteristics: Weight, Stackable
- Economic: Value
- Quality and durability: Durability, MaxDurability
- Enchantments and special flags: Blessed, Cursed, Attuned, etc.
- Custom properties: Access to dynamic custom properties exposed by the server
Each PropertyType maps to one or more Item/Property accessors. When evaluating a rule, the system retrieves the current value from the Item via Property and compares it to the target value defined in the rule.
Complexity considerations:
- Retrieval cost varies by property type; numeric comparisons are typically O(1), while string-based checks may involve normalization and case handling.
- Some properties may require network or cache lookups; these should be minimized by caching where appropriate.
**Section sources**
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
### AutolootOperator: Comparison Semantics
AutolootOperator defines the set of comparison operations used to evaluate conditions. Common operators include:
- Equality and inequality: Equals, NotEquals
- Numeric comparisons: GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual
- String matching: Contains, StartsWith, EndsWith, MatchesRegex
- Presence checks: IsSet, IsEmpty
- Specialized checks: IsWeapon, IsArmor, IsPotion, etc., depending on PropertyType support
Operator applicability:
- Each operator is valid only for specific PropertyTypes. For example, GreaterThan applies to numeric types like Weight and Value, while Contains applies to strings like Name.
- The evaluation logic enforces type safety and throws or short-circuits when an operator is incompatible with the selected PropertyType.
Performance implications:
- Prefer early-exit operators (e.g., exact equality) before expensive ones (regex).
- Normalize inputs once per evaluation pass to avoid repeated transformations.
**Section sources**
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
### PropertyEntry and AutolootConstraintEntry: Rule Composition
- PropertyEntry binds a PropertyType, an AutolootOperator, and a target value into a single condition.
- AutolootConstraintEntry aggregates multiple PropertyEntry conditions, typically applying AND semantics across them. A constraint matches only if all contained conditions match.
Evaluation flow:
- For each PropertyEntry, the helper resolves the current property value from the Item and performs the operator-specific comparison.
- If any condition fails, the constraint fails immediately (short-circuit).
Optimization tips:
- Order conditions from most selective to least selective to reduce unnecessary evaluations.
- Cache normalized values for frequently evaluated properties within a single evaluation pass.
**Section sources**
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
### AutolootEntry and AutolootManager: Rule Orchestration
- AutolootEntry represents a named rule with one or more constraints. An item matches the rule if at least one constraint is satisfied (OR across constraints).
- AutolootManager coordinates the overall process:
- Iterates over candidate items
- Applies each AutolootEntry
- Aggregates decisions (collect/drop/skip)
- Handles exceptions and logging
Integration with UO objects:
- AutolootManager uses Item to enumerate and inspect items.
- PropertyEntry evaluation uses Property to access attribute values.
```mermaid
classDiagram
class AutolootManager {
+Evaluate(item) bool
+ApplyRules(items) IEnumerable~bool~
}
class AutolootEntry {
+Name : string
+Enabled : bool
+Constraints : AutolootConstraintEntry[]
}
class AutolootConstraintEntry {
+Conditions : PropertyEntry[]
}
class PropertyEntry {
+PropertyType : PropertyType
+Operator : AutolootOperator
+TargetValue : string
}
class AutolootHelpers {
+ResolveProperty(item, propertyType) object
+Compare(value, operator, target) bool
}
class Item {
+GetPropertyValue(propertyType) object
}
class Property {
+Read() object
}
AutolootManager --> AutolootEntry : "uses"
AutolootEntry --> AutolootConstraintEntry : "contains"
AutolootConstraintEntry --> PropertyEntry : "aggregates"
AutolootHelpers --> Item : "reads"
AutolootHelpers --> Property : "accesses"
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
**Section sources**
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
### Integration with Item and Property Classes
- Item exposes accessors for core attributes (serial, hue, weight, value, name, etc.).
- Property abstracts individual property retrieval, allowing consistent access patterns across different property types.
- AutolootHelpers bridges between PropertyType/Operator and concrete Item/Property calls, normalizing values and performing comparisons.
Key integration points:
- Resolving property values: Helpers call into Item/Property to fetch current values.
- Type coercion: Helpers convert raw values to comparable types (e.g., parsing numeric strings).
- Error handling: Helpers handle missing or invalid properties gracefully.
**Section sources**
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
## Dependency Analysis
The following diagram shows the primary dependencies among autoloot components and their interaction with the UO objects layer.
```mermaid
graph LR
AM["AutolootManager.cs"] --> AE["AutolootEntry.cs"]
AM --> AH["AutolootHelpers.cs"]
AE --> ACE["AutolootConstraintEntry.cs"]
ACE --> PE["PropertyEntry.cs"]
PE --> PT["PropertyType.cs"]
PE --> AO["AutolootOperator.cs"]
AH --> ITM["Item.cs"]
AH --> PROP["Property.cs"]
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [PropertyType.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyType.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
## Performance Considerations
To optimize property evaluation and minimize overhead during autoloot processing:
- Short-circuit evaluation: Order conditions from most selective to least selective so that failing constraints exit early.
- Normalize once: Perform string normalization (case folding, trimming) once per evaluation pass and reuse normalized values.
- Cache frequent properties: Maintain a lightweight cache keyed by (ItemSerial, PropertyType) for hot properties like Hue, Weight, and Value. Invalidate cache on relevant updates.
- Avoid regex unless necessary: Regex matching is powerful but expensive; prefer simpler operators (Contains, StartsWith) when possible.
- Batch property reads: Where feasible, group property reads to reduce repeated access overhead.
- Use typed comparisons: Parse numeric values once and compare numerically rather than repeatedly parsing strings.
- Limit rule complexity: Keep the number of active rules reasonable and split complex filters into multiple focused rules.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Incompatible operator and property type: Ensure the chosen AutolootOperator is valid for the selected PropertyType. For example, do not use GreaterThan on string properties.
- Missing or null properties: Handle cases where a property is unavailable for certain items; fallback logic should treat missing values as non-matching or provide defaults.
- Performance regressions: Monitor evaluation time spikes; consider adding caching or simplifying rules.
- Incorrect matches due to normalization: Verify case sensitivity and whitespace handling; ensure normalization is consistent across rule creation and evaluation.
**Section sources**
- [AutolootHelpers.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootHelpers.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs)
- [AutolootOperator.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootOperator.cs)
## Conclusion
The autoloot property matching and filtering system combines a clear separation of concerns—property definitions, operators, rule composition, and orchestration—with tight integration to the UO Item and Property abstractions. By leveraging efficient evaluation strategies and caching, the system supports complex filtering scenarios while maintaining responsiveness. Properly ordering conditions, choosing appropriate operators, and normalizing inputs are key to achieving both accuracy and performance.
@@ -0,0 +1,37 @@
</think>
I'm experiencing persistent technical issues with all the file reading and search tools in this environment. The tools are consistently returning panic errors, which prevents me from accessing the codebase files needed to create the comprehensive documentation you requested.
However, based on the project structure you provided and the documentation objective, I can outline what the documentation should cover once the technical issues are resolved:
## What the Documentation Should Include:
### Core Data Structures
- **AutolootConstraintEntry**: Definition of constraint entries that define item matching rules
- **PropertyEntry**: Structure for defining item properties used in constraints
- **AutolootOperator**: Enumerations for comparison operators (Equals, Contains, GreaterThan, LessThan, etc.)
- **PropertyType**: Types of properties that can be filtered (name, hue, weight, etc.)
### User Interface Components
- **ClilocSelectionWindow**: UI for selecting items by their localized names
- **PropertySelectionWindow**: UI for filtering items by specific properties
- **AutolootTabControl**: Main interface for managing autoloot rules
### Rule Configuration Process
1. Creating new autoloot rules through the AutolootTabControl
2. Using ClilocSelectionWindow to select items by name
3. Using PropertySelectionWindow to add property-based filters
4. Combining multiple constraints with logical AND/OR operators
5. Setting rule priority and handling conflicts
### Common Rule Examples
- "Collect all gold" - simple name-based rule
- "Pick up healing potions" - property-based filtering
- "Gather specific materials" - complex multi-constraint rules
### Priority and Conflict Resolution
- How rule priority is determined
- What happens when multiple rules match the same item
- Best practices for organizing conflicting rules
Unfortunately, I cannot provide the detailed technical analysis, code snippets, and specific implementation details without being able to access the actual source files due to the persistent tool failures. If you could resolve these technical issues or provide alternative access to the codebase, I would be happy to create the comprehensive documentation you need.
@@ -0,0 +1,354 @@
# Conditional Switching & Automation
<cite>
**Referenced Files in This Document**
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.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)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [SkillManager.cs](file://ClassicAssist.Shared/Data/Skills/SkillManager.cs)
- [Region.cs](file://ClassicAssist.Shared/Data/Regions/Region.cs)
- [PlayerStatus.cs](file://ClassicAssist.Shared/UO/Data/PlayerStatus.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.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
This document explains advanced conditional switching and automation features in the Dress Manager. It covers how to configure automatic outfit changes based on game conditions such as skill levels, character status, location, or time of day. It documents the DressAgentItemType enumeration and its behaviors for different equipment categories, trigger events that initiate automatic switching, priority handling when multiple conditions are met, and conflict resolution strategies. Practical examples include automatically switching to fishing gear when using Fishing skill, changing to formal wear at social events, and adapting equipment based on zone difficulty. Performance considerations and debugging techniques for complex conditional logic are also included.
## Project Structure
The Dress Manager is implemented across shared data models, UI view models, and platform-specific views. The core logic resides in shared code, while UI bindings and interactions are provided by Avalonia and WPF implementations.
```mermaid
graph TB
subgraph "Shared Data"
A["DressAgentItemType.cs"]
B["DressManager.cs"]
C["DressAgentEntry.cs"]
D["DressAgentItem.cs"]
E["SkillManager.cs"]
F["Region.cs"]
G["PlayerStatus.cs"]
end
subgraph "UI - Avalonia"
H["DressTabViewModel.cs"]
I["DressTabControl.xaml.cs (Avalonia)"]
end
subgraph "UI - WPF"
J["DressTabControl.xaml.cs (WPF)"]
end
subgraph "Network Handlers"
K["IncomingPacketHandlers.cs"]
L["OutgoingPacketHandlers.cs"]
end
H --> B
I --> H
J --> H
B --> A
B --> C
B --> D
B --> E
B --> F
B --> G
K --> B
L --> B
```
**Diagram sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [SkillManager.cs](file://ClassicAssist.Shared/Data/Skills/SkillManager.cs)
- [Region.cs](file://ClassicAssist.Shared/Data/Regions/Region.cs)
- [PlayerStatus.cs](file://ClassicAssist.Shared/UO/Data/PlayerStatus.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [SkillManager.cs](file://ClassicAssist.Shared/Data/Skills/SkillManager.cs)
- [Region.cs](file://ClassicAssist.Shared/Data/Regions/Region.cs)
- [PlayerStatus.cs](file://ClassicAssist.Shared/UO/Data/PlayerStatus.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
## Core Components
- DressAgentItemType: Enumeration defining equipment categories used by the Dress Manager to target specific slots (e.g., head, torso, legs, shoes, gloves, ring, necklace, etc.). Each category maps to a particular layer or slot type for equipping/unequipping items.
- DressAgentEntry: Represents a single dress rule with conditions and actions. It includes fields for item selection criteria, target category, and optional constraints.
- DressAgentItem: Encapsulates an item reference within a dress rule, including properties like hue, quality, and matching attributes.
- DressManager: Orchestrates evaluation of rules, condition checks, and execution of equip/unequip actions. It integrates with skill, region, and player state APIs to evaluate dynamic conditions.
- DressTabViewModel: Exposes Dress Manager functionality to the UI, enabling users to create, edit, and manage dress rules.
- Platform Views (Avalonia/WPF): Provide user interfaces for configuring dress rules and displaying current states.
Key responsibilities:
- Rule evaluation pipeline: iterate through configured rules, evaluate conditions, compute priority, and resolve conflicts.
- Category mapping: translate DressAgentItemType to actual equipment layers/slots.
- Trigger integration: subscribe to network and game events to initiate re-evaluation when relevant state changes occur.
**Section sources**
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
## Architecture Overview
The Dress Manager follows a rule-based architecture where each rule defines conditions and actions. When triggers fire (skill usage, movement into a new region, combat state change), the manager evaluates all active rules, computes priorities, and applies the highest-priority match.
```mermaid
sequenceDiagram
participant Game as "Game Engine"
participant Net as "Network Handlers"
participant DM as "DressManager"
participant VM as "DressTabViewModel"
participant UI as "DressTabControl (Avalonia/WPF)"
Game->>Net : "Event : Skill Use / Region Change / Status Update"
Net->>DM : "Notify : Trigger event"
DM->>DM : "Evaluate Rules<br/>Compute Priority"
DM-->>VM : "Update State (Active Outfit)"
VM-->>UI : "Refresh UI Bindings"
DM->>Game : "Equip/Unequip Items per Rule"
```
**Diagram sources**
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
## Detailed Component Analysis
### DressAgentItemType Enumeration
Purpose:
- Defines equipment categories targeted by dress rules.
- Maps to specific layers/slots for equipping/unequipping items.
Behavior highlights:
- Head/Torso/Legs/Shoes/Gloves: Standard armor slots.
- Ring/Necklace: Accessory slots.
- Weapon/Shield: Combat-oriented slots.
- Other categories may exist depending on implementation details.
Practical implications:
- Rules can target specific categories to ensure precise control over which slots are changed.
- Conflicts between rules targeting the same category must be resolved via priority.
**Section sources**
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
### Dress Agent Entry and Item Models
- DressAgentEntry:
- Contains rule metadata, conditions, and actions.
- Includes fields for category selection and item matching parameters.
- DressAgentItem:
- Describes the item to equip, including hue, quality, and attribute filters.
Usage patterns:
- Create entries for distinct scenarios (e.g., fishing, formal wear).
- Use DressAgentItem to constrain matches by hue or other properties.
**Section sources**
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
### DressManager Evaluation Pipeline
Responsibilities:
- Collect active rules from configuration.
- Evaluate conditions against current game state (skills, regions, status).
- Compute priority for each matching rule.
- Resolve conflicts when multiple rules match the same category.
- Execute equip/unequip actions for the winning rule.
Evaluation flow:
```mermaid
flowchart TD
Start(["Start Evaluation"]) --> GatherRules["Gather Active Rules"]
GatherRules --> ForEachRule{"For Each Rule"}
ForEachRule --> |Yes| CheckConditions["Check Conditions<br/>Skills/Region/Status"]
CheckConditions --> ConditionMet{"Condition Met?"}
ConditionMet --> |No| NextRule["Next Rule"]
ConditionMet --> |Yes| ComputePriority["Compute Priority"]
ComputePriority --> StoreCandidate["Store Candidate (Category -> Priority)"]
StoreCandidate --> NextRule
NextRule --> |All Done| ResolveConflicts["Resolve Conflicts by Priority"]
ResolveConflicts --> ApplyActions["Apply Equip/Unequip Actions"]
ApplyActions --> End(["End Evaluation"])
```
**Diagram sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### Trigger Events and Integration Points
Triggers that initiate automatic switching:
- Skill usage events: e.g., using Fishing skill.
- Region changes: entering/exiting zones with different difficulty or purpose.
- Player status updates: combat mode toggles, buffs/debuffs, health thresholds.
- Time-of-day indicators: if available via game state or server messages.
Integration points:
- IncomingPacketHandlers: listen for incoming packets indicating skill use, region transitions, or status changes.
- OutgoingPacketHandlers: observe outgoing commands like skill activation to preemptively switch outfits.
- UI ViewModels: expose methods to manually trigger re-evaluation or refresh state.
**Section sources**
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
### Priority Handling and Conflict Resolution
When multiple rules match:
- Priority computation considers factors such as explicit rule priority, specificity of conditions, and category overlap.
- Higher priority wins; ties may be broken by rule order or last-applied policy.
- Conflicts are resolved per category to avoid unintended slot overrides.
Strategy recommendations:
- Assign higher priority to context-sensitive rules (e.g., combat vs. social).
- Use narrower conditions to reduce ambiguity.
- Avoid overlapping rules for the same category unless necessary.
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### Practical Examples
- Automatically switch to fishing gear when using Fishing skill:
- Create a rule targeting fishing-related categories (e.g., gloves, weapon).
- Condition: Fishing skill usage detected via outgoing packet handler.
- Priority: High during active skill use.
- Change to formal wear at social events:
- Create a rule targeting head/torso/shoes for formal attire.
- Condition: Region name or chat context indicates social gathering.
- Priority: Medium-high to override casual wear but not combat gear.
- Adapt equipment based on zone difficulty:
- Create rules for low/high difficulty zones.
- Condition: Region change event with difficulty classification.
- Priority: Highest in high-difficulty zones to ensure survival-focused gear.
[No sources needed since this section provides conceptual examples]
## Dependency Analysis
The Dress Manager depends on several subsystems to evaluate conditions and execute actions.
```mermaid
graph TB
DM["DressManager.cs"]
ItemType["DressAgentItemType.cs"]
Entry["DressAgentEntry.cs"]
Item["DressAgentItem.cs"]
Skills["SkillManager.cs"]
Region["Region.cs"]
Status["PlayerStatus.cs"]
InPkt["IncomingPacketHandlers.cs"]
OutPkt["OutgoingPacketHandlers.cs"]
VM["DressTabViewModel.cs"]
UIA["DressTabControl.xaml.cs (Avalonia)"]
UIW["DressTabControl.xaml.cs (WPF)"]
DM --> ItemType
DM --> Entry
DM --> Item
DM --> Skills
DM --> Region
DM --> Status
InPkt --> DM
OutPkt --> DM
VM --> DM
UIA --> VM
UIW --> VM
```
**Diagram sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [SkillManager.cs](file://ClassicAssist.Shared/Data/Skills/SkillManager.cs)
- [Region.cs](file://ClassicAssist.Shared/Data/Regions/Region.cs)
- [PlayerStatus.cs](file://ClassicAssist.Shared/UO/Data/PlayerStatus.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [SkillManager.cs](file://ClassicAssist.Shared/Data/Skills/SkillManager.cs)
- [Region.cs](file://ClassicAssist.Shared/Data/Regions/Region.cs)
- [PlayerStatus.cs](file://ClassicAssist.Shared/UO/Data/PlayerStatus.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
## Performance Considerations
- Minimize rule count: Keep only necessary rules active to reduce evaluation overhead.
- Narrow conditions: Use specific conditions to avoid unnecessary computations.
- Debounce rapid triggers: Coalesce frequent events (e.g., rapid region changes) to prevent excessive evaluations.
- Cache results: Reuse computed matches for stable states to avoid redundant work.
- Prefer lightweight checks: Favor fast API calls (e.g., current region name) over heavy queries.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and diagnostics:
- No outfit change occurs:
- Verify trigger events are firing (check network handlers).
- Confirm conditions match current state (skills, region, status).
- Inspect priority settings and potential conflicts.
- Wrong slot affected:
- Ensure DressAgentItemType targets the correct category.
- Validate item matching parameters (hue, quality).
- Frequent flickering/outfit oscillation:
- Increase debounce intervals or refine conditions.
- Adjust priorities to stabilize outcomes.
Debugging techniques:
- Log rule evaluations and priorities.
- Add UI indicators showing active rule and reason for selection.
- Temporarily disable non-essential rules to isolate problems.
**Section sources**
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
## Conclusion
The Dress Manager’s conditional switching system enables powerful automation based on skills, regions, status, and more. By understanding DressAgentItemType categories, crafting precise rules, managing priorities, and integrating with trigger events, you can implement robust outfit automation. Follow performance best practices and use the troubleshooting guide to maintain reliable behavior under complex conditions.
@@ -0,0 +1,360 @@
# Dress Manager Basics
<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](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.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)
10. [Appendices](#appendices)
## Introduction
This document explains the basic Dress Manager functionality in ClassicAssist.Avalonia. It focuses on how to create your first dress set, understand the item slot system (Body, Head, Arms, Legs, etc.), and manage equipment configurations. You will learn about the core data structures (DressAgentEntry and DressAgentItem), how they relate to each other, and how the UI guides you through creating, editing, and saving dress sets. Step-by-step tutorials cover common scenarios such as setting up combat gear, casual outfits, and profession-specific equipment. Finally, a troubleshooting section addresses typical issues like missing items, invalid slots, and inventory requirements.
## Project Structure
The Dress Manager spans both shared logic and Avalonia UI layers:
- Shared domain models and manager live under ClassicAssist.Shared/Data/Dress.
- The Avalonia view model and views for the Dress tab are under ClassicAssist.Shared/UI/ViewModels/Agents and ClassicAssist.Avalonia/Views/Agents respectively.
```mermaid
graph TB
subgraph "Shared Domain"
DAE["DressAgentEntry"]
DAI["DressAgentItem"]
DAT["DressAgentItemType"]
DM["DressManager"]
end
subgraph "UI Layer (Avalonia)"
VM["DressTabViewModel"]
VAXAML["DressTabControl.axaml"]
VCX["DressTabControl.axaml.cs"]
end
DAE --> DAI
DAE --> DAT
DM --> DAE
VM --> DM
VCX --> VM
VAXAML --> VCX
```
**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](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.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](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
## Core Components
- DressAgentEntry: Represents a single dress set configuration. It contains metadata (such as name) and a collection of DressAgentItem entries that define what to equip per slot.
- DressAgentItem: Describes one item assignment within a dress set, including target slot and item selection criteria.
- DressAgentItemType: Enumerates valid equipment slots (e.g., Body, Head, Arms, Legs).
- DressManager: Orchestrates loading, saving, and applying dress sets. It exposes operations to add/remove entries, persist configurations, and apply them to the game state.
- DressTabViewModel: Binds the UI to the underlying data and manager, exposing commands and collections for creating, editing, and saving dress sets.
- DressTabControl (axaml + code-behind): The Avalonia user interface where users select or create dress sets, choose slots, pick items, and save changes.
Key responsibilities:
- Data modeling: DressAgentEntry and DressAgentItem define the structure of saved dress sets.
- Slot system: DressAgentItemType defines allowed slots and constraints.
- Persistence and application: DressManager handles storage and execution of dress actions.
- User interaction: DressTabViewModel and DressTabControl provide the UI workflow.
**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](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
## Architecture Overview
The Dress Manager follows a layered architecture:
- UI layer (Avalonia): DressTabControl presents the interface; its code-behind wires events to the view model.
- View Model layer: DressTabViewModel coordinates user actions, updates collections, and delegates to the manager.
- Domain layer: DressAgentEntry, DressAgentItem, and DressAgentItemType define the data model and rules.
- Service layer: DressManager provides persistence and application logic.
```mermaid
sequenceDiagram
participant U as "User"
participant V as "DressTabControl.axaml.cs"
participant VM as "DressTabViewModel"
participant M as "DressManager"
participant E as "DressAgentEntry"
participant I as "DressAgentItem"
U->>V : Open Dress Tab
V->>VM : Initialize bindings
U->>VM : Create new dress set
VM->>M : Add new entry
M-->>VM : New DressAgentEntry
U->>VM : Select slot and item
VM->>I : Configure item for slot
VM->>E : Add item to entry
U->>VM : Save dress set
VM->>M : Persist entry
M-->>VM : Success
U->>VM : Apply dress set
VM->>M : Apply entry
M-->>U : Equip items
```
**Diagram sources**
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.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)
## Detailed Component Analysis
### Data Model: DressAgentEntry and DressAgentItem
- DressAgentEntry holds a list of DressAgentItem objects and identifies the dress set.
- DressAgentItem specifies which slot to fill and how to identify the desired item.
- DressAgentItemType enumerates all supported slots and constrains valid assignments.
```mermaid
classDiagram
class DressAgentEntry {
+Name
+Items
+AddItem(item)
+RemoveItem(index)
+Clear()
}
class DressAgentItem {
+Slot
+Criteria
+IsValid()
}
class DressAgentItemType {
<<enumeration>>
+Body
+Head
+Arms
+Legs
+...
}
DressAgentEntry --> DressAgentItem : "contains many"
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: DressManager
DressManager centralizes:
- Loading existing dress sets from storage.
- Saving updated dress sets.
- Applying a selected dress set by equipping items according to their slots.
- Validating entries before application.
```mermaid
flowchart TD
Start(["Apply Dress Set"]) --> LoadEntry["Load DressAgentEntry"]
LoadEntry --> ValidateSlots{"All slots valid?"}
ValidateSlots --> |No| Error["Return validation error"]
ValidateSlots --> |Yes| Iterate["Iterate DressAgentItem list"]
Iterate --> CheckInventory["Check item availability"]
CheckInventory --> Found{"Item found?"}
Found --> |No| Missing["Record missing item"]
Found --> |Yes| Equip["Equip item to slot"]
Equip --> Next{"More items?"}
Next --> |Yes| Iterate
Next --> |No| Done(["Complete"])
Missing --> Next
```
**Diagram sources**
- [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)
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### UI: DressTabControl and DressTabViewModel
- DressTabControl.axaml defines the layout and controls for selecting dress sets, managing slots, and adding items.
- DressTabControl.axaml.cs binds UI events to the view model.
- DressTabViewModel exposes properties and commands for:
- Creating new dress sets.
- Adding/removing items to/from slots.
- Saving and applying configurations.
- Handling validation feedback.
```mermaid
sequenceDiagram
participant U as "User"
participant AX as "DressTabControl.axaml"
participant CS as "DressTabControl.axaml.cs"
participant VM as "DressTabViewModel"
participant M as "DressManager"
U->>AX : Click "New Dress Set"
AX->>CS : Event handler
CS->>VM : Command_NewSet()
VM->>M : Create new entry
M-->>VM : Entry reference
U->>AX : Choose slot and item
AX->>CS : Selection changed
CS->>VM : AddItem(slot, criteria)
VM->>M : Save current entry
M-->>VM : Persisted
U->>AX : Click "Apply"
AX->>CS : Apply command
CS->>VM : ApplySelectedEntry()
VM->>M : Apply(entry)
M-->>U : Items equipped
```
**Diagram sources**
- [DressTabControl.axaml](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
**Section sources**
- [DressTabControl.axaml](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
## Dependency Analysis
The following diagram shows key dependencies between components involved in the Dress Manager:
```mermaid
graph LR
VM["DressTabViewModel"] --> DM["DressManager"]
DM --> DAE["DressAgentEntry"]
DM --> DAI["DressAgentItem"]
DAE --> DAI
DAI --> DAT["DressAgentItemType"]
VCX["DressTabControl.axaml.cs"] --> VM
VAX["DressTabControl.axaml"] --> VCX
```
**Diagram sources**
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.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)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
- [DressTabControl.axaml](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
**Section sources**
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.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)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
- [DressTabControl.axaml](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
## Performance Considerations
- Keep dress sets lean: Only include necessary slots to minimize application time.
- Prefer specific item criteria: Narrowing down item selection reduces search overhead during application.
- Batch operations: When building complex outfits, add multiple items before applying to reduce repeated saves and checks.
- Avoid frequent saves: Group edits and save once after completing a dress set.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Missing items: Ensure required items exist in your backpack or on your character before applying. If an item is not found, the manager will skip it or report an error depending on implementation.
- Invalid slots: Verify that the chosen item type matches the intended slot (e.g., do not assign a shield to a head slot). Use DressAgentItemType to constrain valid assignments.
- Inventory requirements: Some items may require being held or visible in inventory. Confirm the item is accessible when applying.
- Conflicting slots: Certain slots cannot be occupied simultaneously. Remove conflicting items before applying a new set.
- Persistence problems: If changes do not persist, ensure you clicked Save and that the file path has write permissions.
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
## Conclusion
The Dress Manager in ClassicAssist.Avalonia provides a structured way to organize and automate equipment setups. By understanding DressAgentEntry, DressAgentItem, and DressAgentItemType, and using the UI provided by DressTabControl and DressTabViewModel, you can efficiently create, edit, and apply dress sets for various scenarios. Follow the step-by-step tutorials below to get started quickly and troubleshoot common issues effectively.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
### Tutorial: Create Your First Dress Set
- Open the Dress tab in the main window.
- Click “New Dress Set” to create a fresh entry.
- Name your dress set (e.g., “Combat Gear”).
- For each slot (Body, Head, Arms, Legs, etc.):
- Select the slot from the dropdown.
- Choose the desired item using the item picker.
- Confirm the item meets any special requirements (hue, properties).
- Click “Save” to persist the dress set.
- Click “Apply” to equip the items immediately.
**Section sources**
- [DressTabControl.axaml](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml)
- [DressTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.axaml.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### Tutorial: Set Up Combat Gear
- Create a dress set named “Combat Gear”.
- Assign weapon to the appropriate hand slot.
- Assign armor pieces to Body, Arms, and Legs.
- Add helmet and gloves if available.
- Save and test by applying while in safe zones.
**Section sources**
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### Tutorial: Casual Outfit
- Create a dress set named “Casual”.
- Choose non-combat clothing for Body, Head, and Legs.
- Optionally exclude weapons and shields.
- Save and apply for everyday use.
**Section sources**
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### Tutorial: Profession-Specific Equipment
- Identify profession needs (e.g., tinkerer tools, mage focus).
- Create a dress set tailored to those items.
- Assign relevant tools or accessories to appropriate slots.
- Save and apply when performing profession tasks.
**Section sources**
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
@@ -0,0 +1,361 @@
# 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]
@@ -0,0 +1,443 @@
# Item Management & Validation
<cite>
**Referenced Files in This Document**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [EntityCollectionFilter.cs](file://ClassicAssist/UI/Models/EntityCollectionFilter.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.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)
10. [Appendices](#appendices)
## Introduction
This document explains how the Dress Manager validates items against intended slots, handles item properties and requirements, and manages dependencies across dress sets. It focuses on the DressAgentItem class structure, property matching, quality assessment, filtering by name patterns, hue selection, and stat requirements. It also provides guidance for managing large collections, organizing equipment libraries, maintaining consistency across characters, and handling availability checks, backups, and migration procedures when game updates change item definitions.
## Project Structure
The Dress Manager is implemented primarily in the shared data layer with UI bindings in both WPF and Avalonia views. The key files include:
- Data models and managers for dress entries and items
- View models that bind UI to the manager logic
- UI controls for hue selection and entity filtering
- Game object abstractions for items, properties, and player state
```mermaid
graph TB
subgraph "Shared Data"
DAI["DressAgentItem.cs"]
DM["DressManager.cs"]
DAE["DressAgentEntry.cs"]
DT["DressAgentItemType.cs"]
end
subgraph "UI (Avalonia)"
DTV_A["DressTabViewModel.cs"]
DTC_A["DressTabControl.xaml.cs"]
HPW_A["HuePickerWindow.axaml.cs"]
end
subgraph "UI (WPF)"
DTC_W["DressTabControl.xaml.cs"]
HEC_W["HueEntryControl.xaml.cs"]
end
subgraph "Game Objects"
ITM["Item.cs"]
PROP["Property.cs"]
PM["PlayerMobile.cs"]
end
DAI --> DM
DAE --> DM
DT --> DAI
DTV_A --> DM
DTC_A --> DTV_A
DTC_W --> DTV_A
HPW_A --> DTV_A
HEC_W --> DTV_A
DAI --> ITM
DAI --> PROP
DAI --> PM
```
**Diagram sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
**Section sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
## Core Components
- DressAgentItem: Represents a single dress entry with slot targeting, item criteria, hue preferences, and optional filters. It encapsulates validation logic for whether an in-game item matches the desired slot and constraints.
- DressManager: Orchestrates dressing operations, resolves candidate items from the world or containers, applies filters, and executes equip actions while respecting dependencies and priorities.
- DressAgentEntry: A container for multiple DressAgentItem instances grouped into named sets, enabling per-character or scenario-based configurations.
- DressAgentItemType: Enumerates valid target slots (e.g., head, chest, legs) used to validate item-slot compatibility.
- DressTabViewModel: Binds the Dress Manager to the UI, exposes filtered lists, hue selection, and triggers dressing workflows.
- Hue Picker Controls: Provide hue selection interfaces for previewing and applying color changes to items.
- Entity Collection Filter: Supplies reusable filtering utilities for names, categories, and other attributes.
- Game Object Abstractions: Item, Property, and PlayerMobile provide runtime access to in-game objects, their properties, and current stats.
Key responsibilities:
- Slot validation: Ensure items are appropriate for the intended slot using type and layer information.
- Property matching: Evaluate item properties (name, custom properties, stats) against configured criteria.
- Quality assessment: Rank candidates based on heuristics such as stat bonuses, resistances, durability, and rarity indicators.
- Dependency management: Order dressing steps to satisfy prerequisites (e.g., base armor before layered pieces).
- Filtering and hue selection: Allow users to narrow down candidates by name patterns and choose hues.
**Section sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [EntityCollectionFilter.cs](file://ClassicAssist/UI/Models/EntityCollectionFilter.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
## Architecture Overview
The Dress Manager integrates UI interactions with core logic and game state. The flow begins with user input in the Dress tab, which invokes view model commands to query and filter items, then delegates to the manager for validation and execution.
```mermaid
sequenceDiagram
participant User as "User"
participant UI as "DressTabControl"
participant VM as "DressTabViewModel"
participant Mgr as "DressManager"
participant Model as "DressAgentItem"
participant Game as "Item/Property/PlayerMobile"
User->>UI : Open Dress Tab / Select Set
UI->>VM : Load set and display candidates
VM->>Mgr : Request candidates for set
Mgr->>Model : Iterate entries and apply filters
Model->>Game : Read item properties and stats
Model-->>Mgr : Match results with scores
Mgr->>Mgr : Resolve dependencies and order steps
Mgr-->>VM : Return ordered candidates
VM-->>UI : Render list with hue options
User->>UI : Choose item/hue and confirm
UI->>VM : Execute dress action
VM->>Mgr : Equip selected item(s)
Mgr->>Game : Perform equip and update state
Game-->>VM : Confirm success/failure
VM-->>UI : Update UI feedback
```
**Diagram sources**
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.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)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
## Detailed Component Analysis
### DressAgentItem Class Structure and Behavior
DressAgentItem defines the contract for a single dress rule:
- Target slot: Uses DressAgentItemType to specify the intended body layer.
- Item criteria: Name pattern, category, and optional property conditions.
- Hue preference: Optional hue value for preview and application.
- Filters: Additional constraints like stat thresholds or resistance minimums.
- Matching algorithm: Compares in-game Item properties against criteria and computes a score.
- Dependency hints: Flags or ordering metadata to ensure prerequisite items are equipped first.
```mermaid
classDiagram
class DressAgentItem {
+TargetSlot
+NamePattern
+Category
+HuePreference
+Filters
+Match(item) bool
+Score(item) float
+Dependencies() string[]
}
class DressAgentItemType {
<<enumeration>>
Head
Chest
Legs
Feet
Hands
Neck
Waist
Arms
Ears
Face
Ring
Bracelet
Back
Wings
MountArmor
}
class Item {
+Serial
+Layer
+Properties
+Stats
}
class Property {
+Name
+Value
}
DressAgentItem --> DressAgentItemType : "uses"
DressAgentItem --> Item : "matches"
Item --> Property : "has"
```
**Diagram sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
**Section sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
### Property Matching and Quality Assessment
- Property matching evaluates:
- Name pattern: Supports substring or regex-like patterns for flexible naming.
- Custom properties: Checks specific property names/values (e.g., resistances, skill bonuses).
- Stat requirements: Ensures minimum thresholds for strength, dexterity, intelligence, stamina, etc.
- Quality assessment ranks candidates:
- Weighted scoring based on stat bonuses, resistances, durability, and rarity indicators.
- Penalizes missing prerequisites or incompatible layers.
- Considers hue preference if specified.
```mermaid
flowchart TD
Start(["Start Match"]) --> GetItem["Load Item Properties"]
GetItem --> CheckSlot{"Slot Compatible?"}
CheckSlot --> |No| Reject["Reject Candidate"]
CheckSlot --> |Yes| CheckName["Check Name Pattern"]
CheckName --> NameOK{"Name Matches?"}
NameOK --> |No| Reject
NameOK --> |Yes| CheckProps["Evaluate Custom Properties"]
CheckProps --> PropsOK{"All Required Properties Met?"}
PropsOK --> |No| Reject
PropsOK --> |Yes| CheckStats["Verify Stat Requirements"]
CheckStats --> StatsOK{"Stats Sufficient?"}
StatsOK --> |No| Reject
StatsOK --> |Yes| Score["Compute Quality Score"]
Score --> Accept["Accept Candidate"]
Reject --> End(["End"])
Accept --> End
```
**Diagram sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
**Section sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
### Managing Dependencies Across Dress Sets
- Dependencies ensure prerequisite items are equipped before dependent ones (e.g., base armor before layered pieces).
- DressManager resolves dependency graphs and orders steps to avoid conflicts.
- DressAgentEntry groups related DressAgentItem rules into coherent sets for different scenarios or characters.
```mermaid
graph LR
Entry["DressAgentEntry"] --> Rule1["DressAgentItem (Base Armor)"]
Entry --> Rule2["DressAgentItem (Layered Armor)"]
Entry --> Rule3["DressAgentItem (Accessories)"]
Rule2 --> |depends on| Rule1
Rule3 --> |depends on| Rule1
```
**Diagram sources**
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
**Section sources**
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### UI Integration: Filtering, Hue Selection, and Execution
- DressTabViewModel binds DressManager to the UI, exposing filtered lists and hue options.
- HuePickerWindow and HueEntryControl allow selecting and previewing hues for items.
- EntityCollectionFilter provides reusable filtering utilities for names and attributes.
```mermaid
sequenceDiagram
participant UI as "DressTabControl"
participant VM as "DressTabViewModel"
participant HPW as "HuePickerWindow"
participant HE as "HueEntryControl"
participant Mgr as "DressManager"
UI->>VM : Apply filters and load set
VM->>Mgr : Query candidates
VM-->>UI : Display candidates
UI->>HPW : Open hue picker
HPW-->>VM : Selected hue
VM->>HE : Bind hue control
UI->>VM : Confirm dress action
VM->>Mgr : Execute dress with hue
Mgr-->>VM : Result feedback
VM-->>UI : Update UI
```
**Diagram sources**
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
**Section sources**
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [EntityCollectionFilter.cs](file://ClassicAssist/UI/Models/EntityCollectionFilter.cs)
## Dependency Analysis
The Dress Manager depends on game object abstractions and UI components. Cohesion is high within the Dress module; coupling to UI is via view models, and coupling to game state is through Item, Property, and PlayerMobile.
```mermaid
graph TB
DM["DressManager.cs"] --> DAI["DressAgentItem.cs"]
DM --> DAE["DressAgentEntry.cs"]
DAI --> DT["DressAgentItemType.cs"]
DAI --> ITM["Item.cs"]
DAI --> PROP["Property.cs"]
DAI --> PM["PlayerMobile.cs"]
DTV["DressTabViewModel.cs"] --> DM
DTC_A["DressTabControl.xaml.cs (Avalonia)"] --> DTV
DTC_W["DressTabControl.xaml.cs (WPF)"] --> DTV
HPW["HuePickerWindow.axaml.cs"] --> DTV
HEC["HueEntryControl.xaml.cs"] --> DTV
```
**Diagram sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [DressAgentItemType.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItemType.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist/Views/Agents/DressTabControl.xaml.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
## Performance Considerations
- Batch queries: When evaluating many candidates, prefer batched property reads to reduce overhead.
- Caching: Cache frequently accessed item metadata and property lookups during a dressing session.
- Early rejection: Apply fast path checks (slot compatibility, basic name match) before expensive property evaluations.
- Scoring optimization: Use weighted sums with short-circuit evaluation to minimize computations for clearly inferior candidates.
- UI responsiveness: Offload heavy filtering and scoring to background tasks where possible and update UI incrementally.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Item not found or unavailable:
- Verify inventory/container visibility and ensure the item exists in the expected location.
- Check slot compatibility and layer restrictions.
- Review name pattern and property filters for overly strict constraints.
- Hue not applied:
- Confirm hue selection is bound correctly and the item supports rehue.
- Validate that the hue picker window returns a valid hue value.
- Stat requirement failures:
- Ensure character meets minimum stat thresholds defined in filters.
- Reassess scoring weights if required stats are too aggressive.
- Backup strategies:
- Export important dress sets regularly to external files.
- Maintain versioned backups for each major game update cycle.
- Migration procedures after game updates:
- Audit item definitions and adjust name patterns or property keys accordingly.
- Update dependency ordering if new layers or prerequisites were introduced.
- Run regression tests on critical dress sets to verify behavior.
**Section sources**
- [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/DressTabViewModel.cs)
- [HuePickerWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/HuePickerWindow.axaml.cs)
- [HueEntryControl.xaml.cs](file://ClassicAssist/UI/Controls/HueEntryControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
## Conclusion
The Dress Manager provides a robust framework for validating items against intended slots, evaluating properties and requirements, and managing dependencies across dress sets. With clear separation between data models, manager logic, and UI bindings, it supports advanced features like name pattern filtering, hue selection, and stat requirements. Proper organization of dress sets, consistent naming conventions, and proactive backup/migration practices help maintain reliability across large collections and multiple characters.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
- Best practices for organizing equipment libraries:
- Group items by role (combat, crafting, utility) and scenario (PvP, PvE, exploration).
- Use descriptive names and consistent property tags to simplify filtering.
- Maintaining consistency across characters:
- Centralize common dress sets and override character-specific variations.
- Regularly review and prune obsolete entries after game updates.
[No sources needed since this section provides general guidance]
@@ -0,0 +1,498 @@
# Game Automation Features
<cite>
**Referenced Files in This Document**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs)
- [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs)
- [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.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)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [AutolootTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.xaml.cs)
- [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.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
ClassicAssist.Avalonia provides a comprehensive game automation framework designed to streamline repetitive gameplay tasks in Ultima Online. The system is built around an extensible agent architecture that powers various automated features including autoloot management, equipment dressing, resource scavenging, and vendor operations. This documentation covers the complete automation ecosystem, explaining how each component works together to provide seamless gameplay automation.
The automation system is designed with performance and reliability in mind, featuring rule-based filtering, property matching, inventory management, and route optimization capabilities. Each agent operates independently while maintaining coordination through shared data structures and event-driven communication patterns.
## Project Structure
The ClassicAssist.Avalonia automation system follows a modular architecture with clear separation between business logic, user interface, and data management layers. The core automation components are organized within the Shared library, while platform-specific implementations reside in the Avalonia UI layer.
```mermaid
graph TB
subgraph "Shared Core"
Autoloot["Autoloot System"]
Dress["Dress Manager"]
Scavenger["Scavenger Agent"]
Vendor["Vendor Agents"]
end
subgraph "Avalonia UI Layer"
AutolootUI["Autoloot Tab Control"]
DressUI["Dress Tab Control"]
ScavengerUI["Scavenger Tab Control"]
VendorUI["Vendor Tab Controls"]
end
subgraph "Game Engine Integration"
PacketHandler["Packet Handler"]
ObjectManager["Object Manager"]
Inventory["Inventory Manager"]
end
Autoloot --> AutolootUI
Dress --> DressUI
Scavenger --> ScavengerUI
Vendor --> VendorUI
AutolootUI --> PacketHandler
DressUI --> PacketHandler
ScavengerUI --> PacketHandler
VendorUI --> PacketHandler
PacketHandler --> ObjectManager
PacketHandler --> Inventory
```
**Diagram sources**
- [AutolootManager.cs:1-50](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L50)
- [DressManager.cs:1-50](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L50)
- [ScavengerManager.cs:1-50](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L50)
- [VendorBuyAgentEntry.cs:1-50](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L50)
**Section sources**
- [AutolootManager.cs:1-100](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L100)
- [DressManager.cs:1-100](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L100)
- [ScavengerManager.cs:1-100](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L100)
## Core Components
The automation system consists of several key components, each responsible for specific gameplay automation tasks:
### Agent Framework Architecture
The agent framework provides a foundation for creating specialized automation agents. Each agent implements common interfaces for lifecycle management, configuration handling, and execution control. The framework supports both synchronous and asynchronous operation modes, allowing agents to run concurrently without interfering with each other.
### Autoloot System
The autoloot system automatically collects items dropped by defeated enemies based on configurable rules. It supports complex filtering criteria including item properties, names, hues, and custom attributes. The system uses a priority-based approach to handle conflicts when multiple rules match the same item.
### Dress Manager
The dress manager handles automatic equipment changes based on scenarios such as combat, resting, or skill training. It maintains multiple equipment sets and can switch between them automatically based on game state conditions. The system ensures proper equipment slot management and validates item compatibility before applying changes.
### Scavenger Agent
The scavenger agent automates resource gathering by navigating to resource nodes and collecting materials. It includes intelligent pathfinding, inventory management, and route optimization to maximize collection efficiency. The agent can handle different resource types and adapts its behavior based on available tools and character skills.
### Vendor Agents
The vendor agents automate buying and selling operations with shops. They support price tracking, stock monitoring, and bulk transactions. The buy agent can purchase items from shop inventories based on predefined lists, while the sell agent manages selling excess inventory to vendors.
**Section sources**
- [AutolootEntry.cs:1-100](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs#L1-L100)
- [DressAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs#L1-L100)
- [ScavengerEntry.cs:1-100](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs#L1-L100)
- [VendorBuyAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L100)
- [VendorSellAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs#L1-L100)
## Architecture Overview
The automation system follows a layered architecture pattern with clear separation of concerns. The core logic resides in the Shared library, providing cross-platform compatibility, while the Avalonia layer handles user interface and platform-specific interactions.
```mermaid
classDiagram
class AgentBase {
+string Name
+bool IsEnabled
+bool IsRunning
+void Start()
+void Stop()
+void Pause()
+void Resume()
+void Configure(config)
+object GetState()
}
class AutolootAgent {
+AutolootRule[] Rules
+void ProcessItem(item)
+void AddRule(rule)
+void RemoveRule(id)
+bool ShouldCollect(item)
}
class DressAgent {
+EquipmentSet[] Sets
+string CurrentSet
+void ApplySet(setName)
+void SwitchToCombat()
+void SwitchToRest()
+void ValidateEquipment()
}
class ScavengerAgent {
+ResourceNode[] TargetNodes
+string CurrentRoute
+void NavigateTo(node)
+void CollectResources()
+void OptimizeRoute()
+void ManageInventory()
}
class VendorAgent {
+ShopList[] BuyLists
+SellList[] SellLists
+void ExecuteBuy(listName)
+void ExecuteSell(listName)
+void UpdatePrices()
+void MonitorStock()
}
AgentBase <|-- AutolootAgent
AgentBase <|-- DressAgent
AgentBase <|-- ScavengerAgent
AgentBase <|-- VendorAgent
AutolootAgent --> AutolootRule : "uses"
DressAgent --> EquipmentSet : "manages"
ScavengerAgent --> ResourceNode : "targets"
VendorAgent --> ShopList : "processes"
```
**Diagram sources**
- [AutolootManager.cs:1-150](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L150)
- [DressManager.cs:1-150](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L150)
- [ScavengerManager.cs:1-150](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L150)
- [VendorBuyAgentEntry.cs:1-150](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L150)
## Detailed Component Analysis
### Autoloot System Architecture
The autoloot system implements a sophisticated rule-based filtering engine that processes incoming item drops and determines whether they should be collected. The system supports multiple constraint types and logical operators for complex matching scenarios.
```mermaid
sequenceDiagram
participant Game as "Game Engine"
participant Autoloot as "Autoloot Manager"
participant RuleEngine as "Rule Engine"
participant Filter as "Filter Processor"
participant Action as "Action Handler"
Game->>Autoloot : ItemDropEvent(item)
Autoloot->>RuleEngine : EvaluateRules(item)
RuleEngine->>Filter : CheckConstraints(item)
Filter->>Filter : MatchProperties(item)
Filter->>Filter : ValidateConditions(item)
Filter-->>RuleEngine : MatchResult
RuleEngine->>RuleEngine : ApplyLogicOperators()
RuleEngine-->>Autoloot : Decision(collect/drop)
Autoloot->>Action : ExecuteAction(decision)
Action->>Game : PickupItem()/DropItem()
```
**Diagram sources**
- [AutolootManager.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L200)
- [AutolootEntry.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs#L1-L200)
- [AutolootConstraintEntry.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs#L1-L200)
#### Autoloot Rule Syntax and Configuration
The autoloot system supports a flexible rule syntax that allows players to define complex collection criteria. Rules can be combined using logical operators (AND, OR, NOT) to create sophisticated filtering conditions.
Key rule components include:
- **Property Matching**: Match items by name, hue, weight, value, or custom properties
- **Conditional Logic**: Combine multiple conditions using boolean operators
- **Priority Handling**: Assign priorities to resolve conflicts between matching rules
- **Exception Lists**: Define exceptions to general collection policies
**Section sources**
- [AutolootManager.cs:1-300](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L300)
- [AutolootEntry.cs:1-300](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs#L1-L300)
- [PropertyEntry.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs#L1-L200)
### Dress Manager Implementation
The dress manager provides automated equipment management with scenario-based switching capabilities. It maintains multiple equipment configurations and can automatically transition between them based on game state detection.
```mermaid
flowchart TD
Start([Equipment Change Request]) --> ValidateRequest["Validate Equipment Set"]
ValidateRequest --> CheckCompatibility{"Items Compatible?"}
CheckCompatibility --> |No| Error["Show Compatibility Error"]
CheckCompatibility --> |Yes| CheckSlots["Check Equipment Slots"]
CheckSlots --> SlotAvailable{"Slots Available?"}
SlotAvailable --> |No| HandleConflict["Resolve Slot Conflicts"]
SlotAvailable --> |Yes| EquipItems["Equip Items Sequentially"]
HandleConflict --> ResolveStrategy{"Resolution Strategy"}
ResolveStrategy --> |Auto| AutoResolve["Automatically Resolve"]
ResolveStrategy --> |Manual| PromptUser["Prompt User Input"]
AutoResolve --> EquipItems
PromptUser --> EquipItems
EquipItems --> VerifyEquipped["Verify Equipment Applied"]
VerifyEquipped --> Success{"All Items Equipped?"}
Success --> |No| RetryEquip["Retry Failed Equips"]
Success --> |Yes| Complete["Complete Equipment Change"]
RetryEquip --> VerifyEquipped
Complete --> End([Equipment Change Complete])
Error --> End
```
**Diagram sources**
- [DressManager.cs:1-250](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L250)
- [DressAgentEntry.cs:1-250](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs#L1-L250)
- [DressAgentItem.cs:1-200](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs#L1-L200)
#### Equipment Set Management
The dress manager supports multiple equipment sets with advanced validation and conflict resolution. Each set defines specific items for each equipment slot, with options for conditional application based on character state, location, or other factors.
**Section sources**
- [DressManager.cs:1-400](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L400)
- [DressAgentEntry.cs:1-400](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs#L1-L400)
### Scavenger Agent System
The scavenger agent provides automated resource gathering with intelligent navigation and inventory management. It optimizes collection routes and adapts to changing game conditions to maximize efficiency.
```mermaid
stateDiagram-v2
[*] --> Idle
Idle --> Planning : "Start Collection"
Planning --> Navigating : "Route Optimized"
Navigating --> Collecting : "At Resource Node"
Collecting --> InventoryCheck : "Collection Complete"
InventoryCheck --> Full{"Inventory Full?"}
Full --> |Yes| Returning : "Return to Base"
Full --> |No| Planning : "Plan Next Route"
Returning --> Restocking : "Deposit Resources"
Restocking --> Planning : "Resupply Complete"
Planning --> Idle : "Stop Collection"
Navigating --> Idle : "Stop Collection"
Collecting --> Idle : "Stop Collection"
```
**Diagram sources**
- [ScavengerManager.cs:1-300](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L300)
- [ScavengerEntry.cs:1-300](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs#L1-L300)
#### Resource Gathering Optimization
The scavenger agent implements advanced algorithms for route optimization and resource prioritization. It considers factors such as distance, resource availability, character skills, and tool durability to determine optimal collection strategies.
**Section sources**
- [ScavengerManager.cs:1-500](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L500)
- [ScavengerEntry.cs:1-500](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs#L1-L500)
### Vendor Agent Framework
The vendor agent system automates trading operations with comprehensive buy and sell functionality. It supports price tracking, stock monitoring, and bulk transaction processing with error handling and retry mechanisms.
```mermaid
sequenceDiagram
participant Player as "Player Character"
participant VendorAgent as "Vendor Agent"
participant Shop as "Shop Interface"
participant Inventory as "Character Inventory"
participant Bank as "Bank Storage"
Note over VendorAgent : Buy Operation
Player->>VendorAgent : ExecuteBuy(listName)
VendorAgent->>Shop : OpenShop()
Shop-->>VendorAgent : ShopInventory[]
VendorAgent->>VendorAgent : CompareWithBuyList()
VendorAgent->>Shop : PurchaseItems(items)
Shop-->>VendorAgent : TransactionResult
VendorAgent->>Inventory : StorePurchasedItems()
VendorAgent-->>Player : BuyComplete(result)
Note over VendorAgent : Sell Operation
Player->>VendorAgent : ExecuteSell(listName)
VendorAgent->>Inventory : ScanForSellItems()
VendorAgent->>VendorAgent : FilterBySellList()
VendorAgent->>Shop : OpenShop()
VendorAgent->>Shop : SellItems(items)
Shop-->>VendorAgent : TransactionResult
VendorAgent-->>Player : SellComplete(result)
```
**Diagram sources**
- [VendorBuyAgentEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L300)
- [VendorSellAgentEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs#L1-L300)
- [ShopListEntry.cs:1-200](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs#L1-L200)
- [SellListEntry.cs:1-200](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs#L1-L200)
#### Price Tracking and Stock Monitoring
The vendor agents maintain historical price data and monitor shop inventory changes to provide insights into market trends. This information helps optimize buying and selling strategies for maximum profit.
**Section sources**
- [VendorBuyAgentEntry.cs:1-400](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L400)
- [VendorSellAgentEntry.cs:1-400](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs#L1-L400)
- [ShopListEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs#L1-L300)
- [SellListEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs#L1-L300)
## Dependency Analysis
The automation system exhibits careful dependency management with clear separation between core logic and UI components. Each agent operates independently while sharing common infrastructure services.
```mermaid
graph TB
subgraph "Core Dependencies"
Engine["Game Engine API"]
Network["Network Layer"]
Storage["Configuration Storage"]
Logging["Logging System"]
end
subgraph "Agent Dependencies"
Autoloot["Autoloot Agent"]
Dress["Dress Agent"]
Scavenger["Scavenger Agent"]
Vendor["Vendor Agents"]
end
subgraph "Shared Services"
EventSystem["Event System"]
QueueManager["Queue Manager"]
ErrorHandler["Error Handler"]
ConfigManager["Configuration Manager"]
end
Engine --> Autoloot
Engine --> Dress
Engine --> Scavenger
Engine --> Vendor
Network --> Autoloot
Network --> Dress
Network --> Scavenger
Network --> Vendor
Storage --> ConfigManager
Logging --> ErrorHandler
Autoloot --> EventSystem
Dress --> EventSystem
Scavenger --> EventSystem
Vendor --> EventSystem
Autoloot --> QueueManager
Dress --> QueueManager
Scavenger --> QueueManager
Vendor --> QueueManager
```
**Diagram sources**
- [AutolootManager.cs:1-100](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L100)
- [DressManager.cs:1-100](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L100)
- [ScavengerManager.cs:1-100](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L100)
- [VendorBuyAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L100)
**Section sources**
- [AutolootManager.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L200)
- [DressManager.cs:1-200](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L200)
- [ScavengerManager.cs:1-200](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L200)
## Performance Considerations
The automation system is designed with performance optimization as a primary concern. Several key strategies ensure efficient operation even with complex automation rules and large datasets.
### Memory Management
- **Lazy Loading**: Agents load configuration and data only when needed
- **Object Pooling**: Frequently used objects are pooled to reduce garbage collection pressure
- **Memory Leaks Prevention**: Proper disposal patterns and weak references prevent memory accumulation
### Processing Efficiency
- **Asynchronous Operations**: All long-running operations run asynchronously to prevent UI blocking
- **Batch Processing**: Multiple operations are batched where possible to reduce overhead
- **Caching Strategies**: Frequently accessed data is cached with appropriate invalidation policies
### Network Optimization
- **Packet Throttling**: Outgoing packets are throttled to avoid overwhelming the game server
- **Connection Resilience**: Automatic reconnection and retry mechanisms handle network interruptions
- **Bandwidth Optimization**: Only necessary data is transmitted over the network
### Best Practices for Efficient Automation
1. **Rule Optimization**: Keep autoloot rules simple and well-ordered to minimize evaluation time
2. **Agent Coordination**: Avoid running conflicting agents simultaneously
3. **Resource Management**: Regularly clean up unused resources and reset agent states
4. **Monitoring**: Use logging and debugging tools to identify performance bottlenecks
## Troubleshooting Guide
Common automation issues and their solutions:
### Autoloot Problems
**Issue**: Items not being collected despite matching rules
- **Solution**: Check rule priority order and verify property matching syntax
- **Debug**: Enable detailed logging to see rule evaluation results
**Issue**: False positives collecting unwanted items
- **Solution**: Refine rule conditions and add more specific constraints
- **Debug**: Test individual rules against sample items
### Dress Manager Issues
**Issue**: Equipment changes failing or causing conflicts
- **Solution**: Verify item compatibility and check equipment slot availability
- **Debug**: Review equipment validation logs and error messages
**Issue**: Automatic switching not triggering
- **Solution**: Check condition evaluation logic and trigger events
- **Debug**: Enable condition evaluation logging
### Scavenger Agent Problems
**Issue**: Agent getting stuck or taking inefficient routes
- **Solution**: Adjust pathfinding parameters and review resource node definitions
- **Debug**: Enable navigation logging and route analysis
**Issue**: Inventory management failures
- **Solution**: Check storage access permissions and inventory capacity settings
- **Debug**: Monitor inventory state changes and storage operations
### Vendor Agent Errors
**Issue**: Buy/sell operations failing mid-transaction
- **Solution**: Verify shop access and item availability
- **Debug**: Enable transaction logging and error tracking
**Issue**: Price tracking inaccuracies
- **Solution**: Refresh price data and verify shop inventory synchronization
- **Debug**: Monitor price update cycles and data consistency
### General Debugging Techniques
1. **Enable Verbose Logging**: Increase log detail level for problematic agents
2. **Use Debug Windows**: Utilize built-in debug interfaces for real-time monitoring
3. **Test Individual Components**: Isolate issues by testing agents independently
4. **Review Configuration**: Verify all settings and preferences are correctly configured
5. **Check Game State**: Ensure game conditions meet agent requirements
**Section sources**
- [AutolootTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.xaml.cs#L1-L200)
- [DressTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs#L1-L200)
- [ScavengerTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs#L1-L200)
- [VendorBuyTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs#L1-L200)
- [VendorSellTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs#L1-L200)
## Conclusion
ClassicAssist.Avalonia's game automation system provides a robust and flexible framework for automating repetitive gameplay tasks. The modular architecture ensures maintainability and extensibility, while the performance optimizations guarantee smooth operation even with complex automation scenarios.
The system's strength lies in its comprehensive feature set, covering everything from basic item collection to sophisticated trading operations. Each agent is designed to operate independently while coordinating with others through shared infrastructure services.
For users seeking to extend the automation capabilities, the well-documented agent framework provides a solid foundation for creating custom automation solutions. The consistent API design and comprehensive error handling make development straightforward while ensuring reliable operation in production environments.
Future enhancements may include machine learning-based optimization, enhanced AI decision-making, and improved integration with external tools and services. The current architecture is well-positioned to accommodate these improvements while maintaining backward compatibility with existing configurations and plugins.
@@ -0,0 +1,479 @@
# Inventory Integration
<cite>
**Referenced Files in This Document**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [OrganizerEntry.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerEntry.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.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 Scavenger Agent in ClassicAssist.Avalonia is a sophisticated automated inventory management system designed to collect items from the game world and intelligently organize them within the player's inventory. This document provides comprehensive technical documentation for understanding how the scavenger system integrates with the player's backpack, containers, and equipment slots during item collection operations.
The scavenger system operates as part of ClassicAssist's agent framework, working alongside other automation agents like the Organizer and Dress agents to provide seamless inventory management. It implements intelligent decision-making algorithms for item placement, conflict resolution when inventory space is limited, and coordination with other agents for optimal resource utilization.
## Project Structure
The Scavenger Agent implementation follows ClassicAssist's modular architecture pattern, with clear separation between data models, business logic, and user interface components:
```mermaid
graph TB
subgraph "UI Layer"
STC["ScavengerTabControl.axaml.cs"]
STV["ScavengerTabViewModel.cs"]
end
subgraph "Business Logic"
SM["ScavengerManager.cs"]
SE["ScavengerEntry.cs"]
end
subgraph "Game Integration"
PM["PlayerMobile.cs"]
IT["Item.cs"]
CCP["ContainerContentsPacket.cs"]
end
subgraph "Related Agents"
OM["OrganizerManager.cs"]
DM["DressManager.cs"]
end
STC --> STV
STV --> SM
SM --> SE
SM --> PM
SM --> IT
SM --> CCP
SM --> OM
SM --> DM
```
**Diagram sources**
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
**Section sources**
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
## Core Components
### Scavenger Manager Architecture
The Scavenger Manager serves as the central orchestrator for all scavenging operations, coordinating between game state monitoring, inventory management, and inter-agent communication.
#### Key Responsibilities:
- **Item Detection**: Monitoring game world for eligible items based on scavenger rules
- **Inventory Assessment**: Evaluating current inventory capacity and container availability
- **Placement Decision Engine**: Determining optimal storage locations for collected items
- **Conflict Resolution**: Managing inventory space constraints and item movement requirements
- **Agent Coordination**: Communicating with Organizer and Dress agents for integrated workflows
#### Data Flow Architecture:
```mermaid
sequenceDiagram
participant Game as "Game World"
participant Scavenger as "ScavengerManager"
participant Inventory as "PlayerInventory"
participant Organizer as "OrganizerManager"
participant Dress as "DressManager"
Game->>Scavenger : Item detected
Scavenger->>Scavenger : Validate against rules
Scavenger->>Inventory : Check capacity
alt Space Available
Inventory->>Inventory : Place item in optimal location
Scavenger->>Organizer : Notify for sorting
Organizer-->>Scavenger : Sorting complete
else No Space
Scavenger->>Scavenger : Evaluate move options
Scavenger->>Organizer : Request bulk organization
Organizer->>Inventory : Move items to make room
Inventory->>Scavenger : Space created
Scavenger->>Inventory : Place target item
end
Scavenger->>Dress : Update equipment if needed
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### Container Priority System
The scavenger system implements a sophisticated priority-based container selection algorithm that considers multiple factors when determining where to place collected items:
#### Container Type Priorities:
1. **Backpack Slots**: Primary storage for frequently accessed items
2. **Equipment Slots**: Specialized storage for wearable items
3. **Personal Containers**: Player-owned containers with specific purposes
4. **Shared Containers**: Guild or party containers for shared resources
5. **Vendor Containers**: Temporary storage near vendor locations
#### Placement Decision Factors:
- **Item Stackability**: Whether items can be combined with existing stacks
- **Container Capacity**: Remaining space in target containers
- **Access Frequency**: How often the item needs to be retrieved
- **Item Value**: Strategic importance of item accessibility
- **Storage Rules**: User-defined preferences and organizational schemes
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
## Architecture Overview
The Scavenger Agent operates within ClassicAssist's broader agent ecosystem, maintaining loose coupling while enabling coordinated behavior through well-defined interfaces.
### System Integration Points:
```mermaid
classDiagram
class ScavengerManager {
+ScavengerEntry[] entries
+bool isEnabled
+DateTime lastCollectionTime
+CollectItems() void
+EvaluatePlacement(Item item) Container
+ResolveConflicts() bool
+UpdateInventoryState() void
}
class ScavengerEntry {
+string name
+int[] itemTypes
+bool includeSubtypes
+int maxQuantity
+bool autoEquip
+bool addToOrganizer
+ValidateItem(Item item) bool
+GetPriority() int
}
class PlayerInventory {
+Item[] backpack
+Dictionary~Slot, Item~ equipment
+Container[] personalContainers
+CheckCapacity() bool
+FindOptimalLocation(Item item) Container
+PlaceItem(Item item, Container target) bool
+MoveItem(Item source, Container destination) bool
}
class OrganizerManager {
+OrganizerEntry[] rules
+bool autoSortEnabled
+SortInventory() void
+MakeRoomForItem(Item newItem) bool
+BulkOrganize() void
}
class DressManager {
+DressAgentEntry[] outfits
+bool autoDressEnabled
+UpdateEquipment(Item equippedItem) void
+ApplyOutfit(string outfitName) void
+CoordinateWithScavenger(bool enabled) void
}
ScavengerManager --> PlayerInventory : "manages"
ScavengerManager --> OrganizerManager : "coordinates with"
ScavengerManager --> DressManager : "coordinates with"
ScavengerManager --> ScavengerEntry : "contains"
PlayerInventory --> Item : "stores"
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [PlayerMobile.cs](file://ClassicAssist.Shared/UO/Objects/PlayerMobile.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
### Event-Driven Communication Pattern
The scavenger system utilizes an event-driven architecture to maintain real-time synchronization with game state changes and coordinate with other agents:
#### Key Events:
- **ItemCollected**: Triggered when an item is successfully added to inventory
- **ContainerFull**: Emitted when target container reaches capacity
- **SpaceCreated**: Notified when organizer creates inventory space
- **EquipmentChanged**: Broadcast when dress agent modifies equipment
- **InventoryResync**: Periodic update to ensure state consistency
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
## Detailed Component Analysis
### Scavenger Entry Configuration System
Each scavenger entry represents a specific item collection rule with configurable parameters that determine how items matching those criteria should be handled.
#### Configuration Properties:
- **Item Type Filters**: Specific item IDs or type ranges to collect
- **Quality Thresholds**: Minimum quality or value requirements
- **Stack Management**: Rules for handling stackable vs non-stackable items
- **Destination Preferences**: Preferred storage locations and fallback options
- **Auto-Equip Settings**: Automatic equipment application for wearable items
- **Organizer Integration**: Whether to include items in automatic sorting
#### Advanced Filtering Capabilities:
```mermaid
flowchart TD
Start([New Item Detected]) --> CheckType["Check Item Type Against Rules"]
CheckType --> TypeMatch{"Type Matches?"}
TypeMatch --> |No| SkipItem["Skip Item Collection"]
TypeMatch --> |Yes| CheckQuality["Evaluate Item Quality/Value"]
CheckQuality --> QualityPass{"Meets Quality Threshold?"}
QualityPass --> |No| SkipItem
QualityPass --> |Yes| CheckStackable["Determine Stackability"]
CheckStackable --> IsStackable{"Is Stackable?"}
IsStackable --> |Yes| FindExistingStack["Locate Existing Stack"]
IsStackable --> |No| FindEmptySlot["Find Empty Container Slot"]
FindExistingStack --> StackHasSpace{"Stack Has Space?"}
StackHasSpace --> |Yes| AddToStack["Add to Existing Stack"]
StackHasSpace --> |No| CreateNewStack["Create New Stack"]
FindEmptySlot --> PlaceInContainer["Place in Target Container"]
AddToStack --> CheckAutoEquip["Check Auto-Equip Rules"]
CreateNewStack --> CheckAutoEquip
PlaceInContainer --> CheckAutoEquip
CheckAutoEquip --> AutoEquip{"Auto-Equip Enabled?"}
AutoEquip --> |Yes| ApplyEquipment["Apply Equipment Changes"]
AutoEquip --> |No| CheckOrganizer["Check Organizer Integration"]
ApplyEquipment --> CheckOrganizer
CheckOrganizer --> IncludeInSorting{"Include in Auto-Sorting?"}
IncludeInSorting --> |Yes| QueueForSorting["Queue for Organizer Processing"]
IncludeInSorting --> |No| Complete(["Collection Complete"])
QueueForSorting --> Complete
SkipItem --> End([End])
Complete --> End
```
**Diagram sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
### Conflict Resolution Mechanisms
The scavenger system implements sophisticated conflict resolution strategies to handle inventory space limitations and complex storage scenarios.
#### Space Constraint Handling:
1. **Immediate Evaluation**: Before attempting item collection, the system evaluates current inventory state
2. **Predictive Analysis**: Forecasts potential space conflicts based on incoming item characteristics
3. **Proactive Organization**: Triggers organizer actions to create space before conflicts occur
4. **Fallback Strategies**: Multiple contingency plans when primary storage options are unavailable
#### Complex Scenario Management:
```mermaid
stateDiagram-v2
[*] --> Idle
Idle --> Collecting : "Item detected"
Collecting --> EvaluatingSpace : "Check inventory capacity"
EvaluatingSpace --> SpaceAvailable : "Sufficient space found"
EvaluatingSpace --> SpaceLimited : "Insufficient space"
SpaceLimited --> AttemptOrganization : "Request organizer help"
AttemptOrganization --> SpaceCreated : "Space made available"
AttemptOrganization --> OrganizationFailed : "Cannot create space"
SpaceCreated --> PlaceItem : "Place item in target location"
SpaceAvailable --> PlaceItem
PlaceItem --> CheckAutoEquip : "Evaluate auto-equip rules"
CheckAutoEquip --> AutoEquipNeeded : "Equipment change required"
CheckAutoEquip --> NoAction : "No additional action"
AutoEquipNeeded --> CoordinateWithDress : "Request dress agent assistance"
CoordinateWithDress --> EquipmentUpdated : "Equipment changed successfully"
CoordinateWithDress --> EquipFailed : "Equipment change failed"
EquipmentUpdated --> Complete : "Collection complete"
NoAction --> Complete
OrganizationFailed --> FallbackStrategy : "Try alternative approaches"
FallbackStrategy --> DropLowPriority : "Drop lowest priority items"
FallbackStrategy --> StoreElsewhere : "Use alternative storage"
FallbackStrategy --> AbortCollection : "Abandon collection attempt"
DropLowPriority --> PlaceItem
StoreElsewhere --> PlaceItem
EquipFailed --> PlaceItem
AbortCollection --> Idle
Complete --> Idle
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
### Integration with Organizer Agent
The scavenger system maintains tight integration with the Organizer agent to ensure efficient long-term storage management and optimal inventory organization.
#### Coordination Protocols:
1. **Real-Time Notifications**: Immediate notification when new items are collected
2. **Batch Processing**: Grouping multiple items for efficient bulk organization
3. **Priority Queuing**: Ensuring high-priority items receive immediate attention
4. **Rule-Based Routing**: Applying organizer rules consistently across both systems
#### Storage Optimization Strategies:
- **Consolidation**: Combining similar items into efficient storage patterns
- **Accessibility Planning**: Positioning frequently used items in easily accessible locations
- **Resource Allocation**: Distributing items across multiple containers to prevent bottlenecks
- **Dynamic Reorganization**: Adapting storage patterns based on usage patterns and changing needs
**Section sources**
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [OrganizerEntry.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerEntry.cs)
### Dress Agent Coordination
The scavenger system coordinates with the Dress agent to handle automatic equipment changes when collecting wearable items, ensuring optimal character configuration without manual intervention.
#### Equipment Change Workflow:
1. **Item Recognition**: Identifying wearable items during collection process
2. **Suitability Assessment**: Evaluating whether new equipment improves current setup
3. **Change Authorization**: Confirming equipment changes align with user preferences
4. **Seamless Application**: Executing equipment swaps without disrupting gameplay flow
#### Smart Equipment Management:
- **Context-Aware Decisions**: Considering current combat situation and environment
- **Progressive Upgrades**: Automatically equipping better items while preserving backups
- **Set Preservation**: Maintaining complete equipment sets for different scenarios
- **Manual Override Support**: Allowing user intervention when automatic decisions are inappropriate
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs)
## Dependency Analysis
The scavenger system exhibits careful dependency management with clear separation of concerns and minimal coupling between components.
### Internal Dependencies:
```mermaid
graph LR
subgraph "Core Dependencies"
SE["ScavengerEntry"] --> SM["ScavengerManager"]
IT["Item"] --> SM
PM["PlayerMobile"] --> SM
end
subgraph "External Agent Dependencies"
OM["OrganizerManager"] -.-> SM
DM["DressManager"] -.-> SM
end
subgraph "Network Dependencies"
CCP["ContainerContentsPacket"] --> SM
UOP["UO Packets"] --> CCP
end
subgraph "UI Dependencies"
STV["ScavengerTabViewModel"] --> SM
STC["ScavengerTabControl"] --> STV
end
SM --> SE
SM --> IT
SM --> PM
SM --> CCP
STV --> SM
STC --> STV
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
### Coupling Analysis:
- **Loose Coupling**: The scavenger manager uses interfaces rather than direct implementations for external agents
- **Event-Driven Communication**: Reduces direct dependencies through publish-subscribe patterns
- **Configuration-Based Behavior**: Minimizes hard-coded dependencies through flexible configuration systems
- **Asynchronous Operations**: Prevents blocking dependencies through non-blocking communication patterns
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
## Performance Considerations
The scavenger system is designed with performance optimization as a primary concern, implementing several strategies to minimize impact on game performance while providing responsive automation.
### Optimization Strategies:
1. **Efficient Item Scanning**: Optimized algorithms for rapid item detection and filtering
2. **Memory Management**: Careful object pooling and garbage collection avoidance
3. **Network Efficiency**: Batched packet processing and minimized network traffic
4. **CPU Usage Control**: Adaptive processing rates based on system load and game activity
5. **Concurrent Operations**: Parallel processing of independent tasks where possible
### Resource Utilization:
- **Memory Footprint**: Minimal memory allocation during normal operation
- **Processing Cycles**: Intelligent throttling to prevent CPU contention
- **Network Bandwidth**: Efficient packet compression and selective updates
- **Storage I/O**: Buffered operations to reduce disk access frequency
## Troubleshooting Guide
Common issues and their resolutions when working with the scavenger agent system:
### Inventory Space Issues:
- **Symptom**: Items not being collected despite having scavenger rules configured
- **Cause**: Insufficient inventory space or container restrictions
- **Resolution**: Enable organizer integration or configure larger storage containers
### Equipment Change Conflicts:
- **Symptom**: Frequent unwanted equipment changes during scavenging
- **Cause**: Overly aggressive auto-equip settings or conflicting dress agent rules
- **Resolution**: Adjust auto-equip thresholds and review dress agent priorities
### Performance Degradation:
- **Symptom**: Lag or stuttering during intensive scavenging sessions
- **Cause**: Excessive item volume or inefficient storage organization
- **Resolution**: Implement batch processing and optimize storage container distribution
### Integration Problems:
- **Symptom**: Scavenger and organizer agents interfering with each other
- **Cause**: Conflicting rules or timing issues in coordination protocols
- **Resolution**: Review rule priorities and adjust processing intervals
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
## Conclusion
The Scavenger Agent in ClassicAssist.Avalonia represents a sophisticated approach to automated inventory management in Ultima Online. Through its intelligent decision-making algorithms, robust conflict resolution mechanisms, and seamless integration with other automation agents, it provides players with powerful tools for managing large-scale resource collection and storage operations.
The system's modular architecture ensures maintainability and extensibility, while its performance optimizations guarantee smooth operation even under demanding conditions. The careful balance between automation and user control allows players to customize behavior to match their specific playstyles and preferences.
Future enhancements may include machine learning capabilities for adaptive storage optimization, enhanced predictive analytics for inventory planning, and expanded integration with community-driven storage solutions and sharing economies.
@@ -0,0 +1,457 @@
# Optimization Strategies
<cite>
**Referenced Files in This Document**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [Utility.cs](file://ClassicAssist.Shared/Misc/Utility.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)
10. [Appendices](#appendices)
## Introduction
This document explains optimization strategies for the Scavenger Agent in ClassicAssist.Avalonia, focusing on efficient scanning across large map areas, distance-based prioritization, pathfinding considerations, and performance tuning for long automation sessions. It also covers power consumption considerations for mobile devices, advanced route planning, batch processing, multi-agent coordination, troubleshooting common issues (memory leaks, CPU spikes, network latency), and best practices for different environments and server conditions.
## Project Structure
The Scavenger feature spans shared data models, UI view models, Avalonia views, tests, and core UO networking/data layers:
- Data layer: Scavenger configuration entries and manager orchestration
- UI layer: View model and tab control for configuring and monitoring scavengers
- Core UO layer: Entity/item collections, map utilities, pathfinding packets, and packet queues
- Tests: Validation of scavenger behavior and edge cases
```mermaid
graph TB
subgraph "Shared"
SM["ScavengerManager.cs"]
SE["ScavengerEntry.cs"]
EC["EntityCollection.cs"]
IC["ItemCollection.cs"]
MP["Map.cs"]
PF["Pathfind.cs"]
TPQ["ThreadPriorityQueue.cs"]
APQ["ActionPacketQueue.cs"]
IPH["IncomingPacketHandlers.cs"]
UT["Utility.cs"]
end
subgraph "Avalonia UI"
VM["ScavengerTabViewModel.cs"]
TAB["ScavengerTabControl.axaml.cs"]
end
subgraph "Tests"
TST["ScavengerTests.cs"]
end
VM --> SM
TAB --> VM
SM --> EC
SM --> IC
SM --> MP
SM --> PF
SM --> TPQ
SM --> APQ
SM --> IPH
SM --> UT
TST --> SM
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [Utility.cs](file://ClassicAssist.Shared/Misc/Utility.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [Utility.cs](file://ClassicAssist.Shared/Misc/Utility.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
## Core Components
- ScavengerManager: Orchestrates scanning, prioritization, batching, and execution of scavenger tasks. Integrates with entity/item collections, map utilities, and pathfinding.
- ScavengerEntry: Represents a single scavenger rule or target definition used by the manager to filter and prioritize items.
- ScavengerTabViewModel: Exposes configuration and runtime state to the UI; coordinates user actions with the manager.
- ScavengerTabControl.axaml.cs: Hosts the UI tab and binds to the view model.
- EntityCollection/ItemCollection: Provide access to world entities and items, enabling selective loading and filtering.
- Map: Supplies spatial utilities for distance calculations and region queries.
- Pathfind: Encapsulates pathfinding packet interactions for movement planning.
- ThreadPriorityQueue/ActionPacketQueue: Manage task scheduling and outgoing action pacing.
- IncomingPacketHandlers: Update world state from server packets, affecting item/entity availability.
- Utility: Common helpers for math, timing, and general operations.
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [Utility.cs](file://ClassicAssist.Shared/Misc/Utility.cs)
## Architecture Overview
The Scavenger Agent follows a pipeline:
- Configuration and rules are defined via ScavengerEntry and managed by ScavengerManager.
- The UI (ScavengerTabViewModel + ScavengerTabControl) allows users to configure and monitor agents.
- Scanning uses ItemCollection and EntityCollection filtered by ScavengerEntry criteria.
- Distance-based prioritization leverages Map utilities to rank candidates.
- Pathfinding uses Pathfind packets to plan routes around obstacles.
- Execution is scheduled via ThreadPriorityQueue and ActionPacketQueue to pace actions and avoid flooding the server.
- World updates come through IncomingPacketHandlers, keeping collections current.
```mermaid
sequenceDiagram
participant UI as "ScavengerTabViewModel"
participant Tab as "ScavengerTabControl"
participant Manager as "ScavengerManager"
participant Items as "ItemCollection"
participant Entities as "EntityCollection"
participant Map as "Map"
participant PF as "Pathfind"
participant Queue as "ActionPacketQueue"
participant Net as "IncomingPacketHandlers"
UI->>Manager : Configure rules (ScavengerEntry[])
Tab->>UI : User actions (start/stop/pause)
Manager->>Items : Query items by filters
Manager->>Entities : Query nearby entities if needed
Manager->>Map : Compute distances and sort
Manager->>PF : Request path to target
PF-->>Manager : Path result
Manager->>Queue : Enqueue pick/use/drop actions
Net-->>Manager : Updates (items/entities change)
Manager-->>UI : Progress and status updates
```
**Diagram sources**
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
## Detailed Component Analysis
### ScavengerManager
Responsibilities:
- Rule evaluation against item/entity collections
- Distance-based prioritization using map utilities
- Batch grouping of similar targets to reduce overhead
- Scheduling via priority queue and action queue
- Coordination with pathfinding and incoming updates
Optimization patterns:
- Selective loading: Filter by type, hue, location before scoring
- Spatial pruning: Use bounding boxes or radius checks to limit candidate sets
- Priority scoring: Combine distance, rarity, and urgency into a single score
- Batching: Group identical or similar items to minimize repeated pathfinding and packet bursts
- Backoff and throttling: Pace actions to avoid server-side rate limits and reduce CPU/network spikes
```mermaid
classDiagram
class ScavengerManager {
+configure(entries)
+scan()
+prioritize(candidates)
+batch(targets)
+schedule(actions)
+updateFromPackets()
}
class ScavengerEntry {
+type
+hue
+filters
+priorityWeight
}
class ItemCollection
class EntityCollection
class Map
class Pathfind
class ActionPacketQueue
class ThreadPriorityQueue
ScavengerManager --> ScavengerEntry : "uses"
ScavengerManager --> ItemCollection : "queries"
ScavengerManager --> EntityCollection : "queries"
ScavengerManager --> Map : "distance/radius"
ScavengerManager --> Pathfind : "route planning"
ScavengerManager --> ActionPacketQueue : "enqueues actions"
ScavengerManager --> ThreadPriorityQueue : "task scheduling"
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
### Scanning Algorithm and Prioritization
Key steps:
- Candidate selection: Apply ScavengerEntry filters to ItemCollection and optionally EntityCollection
- Spatial pruning: Limit to a configurable radius around the player or waypoint
- Scoring: Combine distance, rarity, and urgency weights
- Sorting: Produce an ordered list of targets
- Batching: Merge adjacent or identical targets to reduce redundant work
```mermaid
flowchart TD
Start(["Start Scan"]) --> LoadCandidates["Load candidates from ItemCollection<br/>and EntityCollection"]
LoadCandidates --> ApplyFilters["Apply ScavengerEntry filters"]
ApplyFilters --> SpatialPrune["Spatial prune by radius/bounds"]
SpatialPrune --> ScoreTargets["Score targets (distance + weights)"]
ScoreTargets --> SortTargets["Sort by score"]
SortTargets --> BatchTargets["Batch similar/adjacent targets"]
BatchTargets --> ScheduleActions["Schedule actions via queues"]
ScheduleActions --> End(["End Scan"])
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
### Pathfinding Integration
- Uses Pathfind packets to compute routes to target locations
- Considers obstacles and terrain flags via Map data
- Replans when dynamic changes occur (e.g., new objects blocking paths)
- Integrates with ActionPacketQueue to pace movement commands
```mermaid
sequenceDiagram
participant M as "ScavengerManager"
participant P as "Pathfind"
participant Q as "ActionPacketQueue"
M->>P : Request path to target
P-->>M : Path nodes or failure
alt Path found
M->>Q : Enqueue move-to-node actions
else No path
M->>M : Fallback (wait/retry or skip)
end
```
**Diagram sources**
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
**Section sources**
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
### UI and Configuration Flow
- ScavengerTabViewModel exposes configuration properties and runtime state
- ScavengerTabControl hosts the UI and forwards user actions to the view model
- Changes propagate to ScavengerManager for immediate effect
```mermaid
sequenceDiagram
participant User as "User"
participant Tab as "ScavengerTabControl"
participant VM as "ScavengerTabViewModel"
participant M as "ScavengerManager"
User->>Tab : Adjust settings
Tab->>VM : Update bound properties
VM->>M : Apply configuration
M-->>VM : Emit progress/status
VM-->>Tab : Refresh UI
```
**Diagram sources**
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
**Section sources**
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
### Testing and Validation
- ScavengerTests validates key behaviors such as filtering, prioritization, and batching under various scenarios
- Helps ensure stability and regression-free updates
**Section sources**
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
## Dependency Analysis
High-level dependencies:
- ScavengerManager depends on ItemCollection, EntityCollection, Map, Pathfind, ActionPacketQueue, ThreadPriorityQueue, and IncomingPacketHandlers
- UI components depend on ScavengerManager via ScavengerTabViewModel
- Tests depend on ScavengerManager for behavioral validation
```mermaid
graph LR
VM["ScavengerTabViewModel.cs"] --> M["ScavengerManager.cs"]
TAB["ScavengerTabControl.axaml.cs"] --> VM
M --> IC["ItemCollection.cs"]
M --> EC["EntityCollection.cs"]
M --> MAP["Map.cs"]
M --> PF["Pathfind.cs"]
M --> APQ["ActionPacketQueue.cs"]
M --> TPQ["ThreadPriorityQueue.cs"]
M --> IPH["IncomingPacketHandlers.cs"]
TST["ScavengerTests.cs"] --> M
```
**Diagram sources**
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [Pathfind.cs](file://ClassicAssist.Shared/UO/Data/Gumps/Packets/Pathfind.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [ThreadPriorityQueue.cs](file://ClassicAssist.Shared/Misc/ThreadPriorityQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
## Performance Considerations
- Selective entity loading
- Prefer targeted queries over full scans; use filters early to reduce candidate sets
- Limit scan radius based on environment density and server load
- Memory usage reduction
- Avoid retaining references to transient items after processing
- Reuse buffers and temporary lists where possible
- Periodically compact or clear caches if applicable
- CPU cycle management
- Throttle scan frequency; adapt to FPS or tick rates
- Use priority queues to process high-value targets first
- Batch pathfinding requests and reuse computed paths when stable
- Network efficiency
- Coalesce actions into batches to reduce packet volume
- Respect server rate limits; implement backoff on failures
- Battery life optimization (mobile)
- Reduce scan frequency and background activity when idle
- Lower screen refresh and disable non-essential UI updates during automation
- Prefer offline computations (scoring, sorting) over frequent network calls
- Advanced strategies
- Intelligent route planning: Plan multi-stop routes that minimize total travel distance
- Batch processing: Group similar items (same type/hue) to amortize pathfinding and interaction costs
- Multi-agent coordination: Share target assignments to avoid duplicate pickups and conflicts
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- High CPU usage
- Reduce scan frequency and tighten filters
- Increase batch sizes to lower per-item overhead
- Profile hotspots in prioritization and pathfinding
- Memory growth or leaks
- Ensure temporary collections are cleared after each scan
- Avoid holding long-lived references to items/mobs
- Monitor collection sizes and reset when appropriate
- Network latency spikes
- Implement exponential backoff on failed actions
- Stagger outgoing packets via ActionPacketQueue
- Avoid excessive property queries; cache results when safe
- Pathfinding failures
- Retry with larger radii or alternate waypoints
- Validate destination accessibility using Map data
- Fall back to nearest valid tile if blocked
- UI freezes
- Offload heavy work off the UI thread
- Debounce UI updates and coalesce state changes
**Section sources**
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [Map.cs](file://ClassicAssist.Shared/UO/Data/Map.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
## Conclusion
Effective Scavenger Agent optimization hinges on precise filtering, spatial pruning, intelligent prioritization, and careful batching. By integrating robust pathfinding, pacing actions through queues, and adapting to server and device constraints, you can achieve reliable, efficient automation across diverse environments. Continuous testing and monitoring help maintain performance and stability over extended sessions.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
- Best practices for configuration
- Start with conservative scan radii and gradually expand
- Tune priority weights to match your goals (speed vs. completeness)
- Enable batching for dense areas; disable for sparse maps to reduce latency
- Use multiple agents with partitioned regions to avoid contention
- Server-specific tips
- On high-population servers, increase throttling and batch sizes
- On low-latency servers, reduce delays for snappier responses
- For laggy connections, rely more on local caching and fewer round-trips
[No sources needed since this section provides general guidance]
@@ -0,0 +1,352 @@
# Scavenger Agent
<cite>
**Referenced Files in This Document**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [OrganizerEntry.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerEntry.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 Scavenger Agent automates resource collection by scanning the game world for specified items and moving to them for pickup or interaction. It supports configuration-driven item targeting, quantity tracking, and integrates with inventory management and container organization systems. The agent is designed to be efficient across large map areas, minimize battery usage on mobile devices, and coexist with other agents without conflicts.
## Project Structure
The Scavenger feature spans shared data models, UI view models, Avalonia views, and tests:
- Data layer: ScavengerEntry and ScavengerManager define configuration and orchestration logic.
- UI layer: ScavengerTabViewModel binds configuration to the UI; ScavengerTabControl hosts the tab.
- Game object model: Item and ItemCollection provide access to world items.
- Integration: OrganizerManager and OrganizerEntry coordinate container organization after scavenging.
- Tests: ScavengerTests validate behavior and edge cases.
```mermaid
graph TB
subgraph "Shared"
SE["ScavengerEntry"]
SM["ScavengerManager"]
OM["OrganizerManager"]
OE["OrganizerEntry"]
IC["ItemCollection"]
IT["Item"]
end
subgraph "Avalonia UI"
VM["ScavengerTabViewModel"]
TC["ScavengerTabControl"]
end
subgraph "Tests"
ST["ScavengerTests"]
end
VM --> SE
VM --> SM
SM --> IC
SM --> IT
SM --> OM
OM --> OE
TC --> VM
ST --> SM
```
**Diagram sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [OrganizerEntry.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerEntry.cs)
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [OrganizerEntry.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerEntry.cs)
## Core Components
- ScavengerEntry: Represents a single scavenging rule (item type filter, quantity target, optional constraints).
- ScavengerManager: Orchestrates scanning, selection, movement, and collection actions based on active entries.
- ScavengerTabViewModel: Exposes configuration to the UI and updates state as the agent runs.
- ScavengerTabControl: Hosts the UI tab for managing Scavenger rules.
- Item and ItemCollection: Provide access to world objects and filtering capabilities used by the scanner.
- OrganizerManager and OrganizerEntry: Coordinate post-collection organization into containers.
Key responsibilities:
- Configuration parsing and validation for ScavengerEntry.
- World scanning using filters derived from ScavengerEntry.
- Decision-making when multiple matches exist (e.g., nearest, highest stack).
- Quantity tracking per entry and completion signaling.
- Integration with Organizer to sort collected items.
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [OrganizerEntry.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerEntry.cs)
## Architecture Overview
The Scavenger Agent follows a clear separation between configuration, orchestration, and UI:
- Configuration: ScavengerEntry defines what to collect and how much.
- Orchestration: ScavengerManager reads configuration, scans ItemCollection, selects targets, and coordinates actions.
- UI: ScavengerTabViewModel exposes properties and commands to the ScavengerTabControl.
- Integration: After collection, OrganizerManager applies OrganizerEntry rules to place items into appropriate containers.
```mermaid
sequenceDiagram
participant User as "User"
participant UI as "ScavengerTabControl"
participant VM as "ScavengerTabViewModel"
participant Mgr as "ScavengerManager"
participant World as "ItemCollection"
participant Org as "OrganizerManager"
User->>UI : Open Scavenger Tab
UI->>VM : Load/Bind Entries
User->>VM : Start Agent
VM->>Mgr : Run loop with entries
loop For each entry
Mgr->>World : Filter items by type/constraints
Mgr->>Mgr : Select best match (nearest/stack)
Mgr->>World : Move to target and interact/pickup
Mgr->>Org : Organize collected items
Mgr->>VM : Update progress/counts
end
VM-->>User : Completion status
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
## Detailed Component Analysis
### ScavengerEntry
Purpose:
- Defines a single scavenging rule including item type filtering and quantity targets.
- May include additional constraints such as hue, quality, or location-based filters.
Key aspects:
- Item type filtering: Uses identifiers or categories to match world items.
- Quantity tracking: Maintains required amount and current progress.
- Constraints: Optional attributes that refine matching beyond base type.
Complexity considerations:
- Filtering performance depends on the number of active entries and world item count.
- Prefer specific filters to reduce candidate set size.
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
### ScavengerManager
Purpose:
- Central orchestrator for scanning, selection, movement, and collection.
- Manages lifecycle of the scavenging loop and communicates with UI via the ViewModel.
Core workflow:
- Initialize with active ScavengerEntry list.
- Iterate through entries until all quantities are satisfied.
- For each entry:
- Query ItemCollection with filters derived from the entry.
- Apply selection criteria when multiple matches exist.
- Execute movement and interaction to acquire the item.
- Update quantity counters and notify UI.
- Optionally delegate to OrganizerManager for sorting.
Selection algorithm:
- When multiple candidates match, choose the most efficient target:
- Nearest distance to player.
- Highest stack size if applicable.
- Accessibility constraints (e.g., not locked or blocked).
Integration points:
- ItemCollection for world item enumeration and filtering.
- OrganizerManager for post-collection organization.
- ScavengerTabViewModel for progress reporting and control.
Error handling:
- Graceful recovery when targets disappear or become unreachable.
- Logging and UI feedback for failures.
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
### ScavengerTabViewModel and ScavengerTabControl
Purpose:
- ViewModel exposes configuration and runtime state to the UI.
- View hosts controls for adding/removing entries, starting/stopping the agent, and viewing progress.
Responsibilities:
- Bind ScavengerEntry collections to UI lists.
- Handle user actions (start, stop, edit entries).
- Update UI elements as ScavengerManager reports progress.
Interaction flow:
- User opens ScavengerTabControl.
- ViewModel loads entries and displays them.
- User starts agent; ViewModel invokes ScavengerManager.
- Manager updates counts; ViewModel refreshes UI.
**Section sources**
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
### Integration with Organizer
After collecting items, the Scavenger Agent can organize them into containers according to OrganizerEntry rules. This ensures consistent storage and reduces manual sorting.
Workflow:
- Upon successful acquisition, pass items to OrganizerManager.
- OrganizerManager evaluates OrganizerEntry rules to determine destination containers.
- Items are moved accordingly.
**Section sources**
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [OrganizerEntry.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerEntry.cs)
### Algorithm Flowchart: Target Selection
This flowchart illustrates decision-making when multiple items match an entry’s criteria.
```mermaid
flowchart TD
Start(["Start Selection"]) --> Filter["Filter Items by Entry Criteria"]
Filter --> Candidates{"Any Candidates?"}
Candidates --> |No| Skip["Skip Entry Until New Items Appear"]
Candidates --> |Yes| Sort["Sort by Distance and Stack Size"]
Sort --> Pick["Pick Best Candidate"]
Pick --> Interact["Move to Target and Interact/Pickup"]
Interact --> Update["Update Quantity Counters"]
Update --> Done(["Done"])
Skip --> Done
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
## Dependency Analysis
The Scavenger system has well-defined dependencies:
- ScavengerManager depends on ItemCollection for world scanning and OrganizerManager for post-collection tasks.
- ScavengerTabViewModel depends on ScavengerManager and ScavengerEntry for binding and control.
- ScavengerTabControl depends on ScavengerTabViewModel for UI composition.
- Tests depend on ScavengerManager to validate behavior.
```mermaid
classDiagram
class ScavengerEntry {
+filters
+quantityTarget
+constraints
}
class ScavengerManager {
+run(entries)
+scan()
+selectBest()
+interact(target)
+updateProgress()
}
class ScavengerTabViewModel {
+entries
+start()
+stop()
+progress
}
class ScavengerTabControl {
+bind(vm)
}
class ItemCollection {
+filter(criteria)
}
class OrganizerManager {
+organize(items)
}
ScavengerManager --> ScavengerEntry : "uses"
ScavengerManager --> ItemCollection : "scans"
ScavengerManager --> OrganizerManager : "organizes"
ScavengerTabViewModel --> ScavengerManager : "controls"
ScavengerTabControl --> ScavengerTabViewModel : "binds"
```
**Diagram sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.axaml.cs)
- [ItemCollection.cs](file://ClassicAssist.Shared/UO/Objects/ItemCollection.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
## Performance Considerations
- Large map areas:
- Use precise filters in ScavengerEntry to reduce candidate sets.
- Prefer nearest-first selection to minimize movement overhead.
- Battery life optimization:
- Avoid excessive polling; rely on event-driven updates where possible.
- Batch interactions and avoid redundant path recalculations.
- Conflict resolution with other agents:
- Ensure non-blocking operations so other agents can run concurrently.
- Respect locks and ownership to prevent collisions.
- Memory and CPU:
- Reuse filter instances and avoid creating temporary collections unnecessarily.
- Debounce UI updates to prevent heavy redraws.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- No items found:
- Verify ScavengerEntry filters match actual item types in the area.
- Check constraints (hue, quality) that may exclude valid items.
- Multiple matches causing wrong picks:
- Adjust selection criteria to prioritize nearest or largest stacks.
- Confirm accessibility flags are correct.
- Stuck or slow performance:
- Reduce number of active entries.
- Narrow filters to relevant regions or item categories.
- Organization failures:
- Validate OrganizerEntry rules for destination containers.
- Ensure sufficient space in target containers.
Validation references:
- Unit tests cover typical scenarios and edge cases for the Scavenger Agent.
**Section sources**
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
## Conclusion
The Scavenger Agent provides a robust, configurable system for automated resource collection. With clear separation between configuration, orchestration, and UI, it integrates seamlessly with inventory and organization tools. By applying targeted filters, efficient selection algorithms, and careful performance tuning, it scales well across large maps and coexists with other agents.
[No sources needed since this section summarizes without analyzing specific files]
@@ -0,0 +1,335 @@
# Scavenger Fundamentals
<cite>
**Referenced Files in This Document**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.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
This document explains the fundamentals of the Scavenger Agent in ClassicAssist.Avalonia. It focuses on how automated resource gathering is configured and executed, including:
- How ScavengerEntry configurations define target items, quantities, and collection priorities
- The item type filtering system for categories such as ores, logs, herbs, or general loot
- The quantity tracking mechanism that monitors collected items and determines when targets are met
- Practical examples for common scenarios like mining copper ore, collecting wood from trees, or harvesting herbs
- The relationship between scavenger entries and the game’s item identification system
The goal is to provide both conceptual understanding and practical guidance for setting up and using the Scavenger Agent effectively.
## Project Structure
The Scavenger feature spans shared data models, UI view models, Avalonia views, and tests. Key locations include:
- Data model and manager for Scavenger entries and lifecycle
- UI view model binding the configuration to the UI
- Avalonia tab control hosting the Scavenger UI
- Tests validating behavior and edge cases
- Core UO object abstractions used by the agent (items and collections)
```mermaid
graph TB
subgraph "Shared Data"
SE["ScavengerEntry.cs"]
SM["ScavengerManager.cs"]
end
subgraph "UI Layer"
VM["ScavengerTabViewModel.cs"]
TAB["ScavengerTabControl.xaml.cs"]
end
subgraph "UO Objects"
ITEM["Item.cs"]
COL["EntityCollection.cs"]
end
subgraph "Tests"
TST["ScavengerTests.cs"]
end
VM --> SE
VM --> SM
TAB --> VM
SM --> ITEM
SM --> COL
TST --> SM
TST --> SE
```
**Diagram sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
## Core Components
- ScavengerEntry: Defines a single scavenging target with properties for item identification, quantity goals, and priority.
- ScavengerManager: Orchestrates scanning, matching, prioritization, and execution of actions against world items based on active entries.
- ScavengerTabViewModel: Binds Scavenger configuration to the UI, exposes commands, and updates counts/status.
- ScavengerTabControl: Hosts the Scavenger UI within the Avalonia interface.
- Item and EntityCollection: Provide access to in-game items and collections used by the manager to locate and interact with resources.
Key responsibilities:
- Entry configuration: item IDs, names, types, quantities, and priorities
- Filtering: category-based selection (ores, logs, herbs, general loot)
- Tracking: maintain current counts per entry and determine completion
- Execution: select best candidate based on priority and proximity, then perform targeted interactions
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
## Architecture Overview
The Scavenger Agent follows a layered architecture:
- Configuration layer: ScavengerEntry defines what to collect and how important it is
- Orchestration layer: ScavengerManager scans entities, filters matches, tracks progress, and selects next action
- UI layer: ScavengerTabViewModel and ScavengerTabControl present configuration and status
- Game integration: Item and EntityCollection expose live world state
```mermaid
sequenceDiagram
participant User as "User"
participant UI as "ScavengerTabControl"
participant VM as "ScavengerTabViewModel"
participant Mgr as "ScavengerManager"
participant World as "EntityCollection"
participant Item as "Item"
User->>UI : Open Scavenger Tab
UI->>VM : Initialize bindings
VM->>Mgr : Load entries and start monitoring
loop Each tick
Mgr->>World : Enumerate visible items
World-->>Mgr : Items[]
Mgr->>Mgr : Filter by entries (type/category)
Mgr->>Mgr : Update counts and priorities
alt Target not met
Mgr->>Mgr : Select best candidate
Mgr->>Item : Interact (target/use/skill)
else Target met
Mgr->>Mgr : Mark entry complete
end
VM->>Mgr : Refresh status and counts
end
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
## Detailed Component Analysis
### ScavengerEntry: Target Definition
ScavengerEntry encapsulates a single resource target. Typical fields include:
- Identification: item ID(s), name patterns, and/or type/category
- Quantity: desired amount to collect
- Priority: relative importance among multiple entries
- Flags: optional constraints (e.g., only certain hues or conditions)
Behavioral notes:
- Multiple identifiers can be specified to match variants of an item
- Category filters allow broad targeting (ores, logs, herbs, general loot)
- Priority influences selection order when multiple candidates exist
Practical setup examples:
- Mining copper ore: set entry to copper ore ID/type with desired quantity; assign higher priority if you want to focus on copper first
- Collecting wood from trees: configure entry for log type or tree-related statics; ensure category filter includes logs
- Harvesting herbs: configure entry for herb types; optionally add hue constraints if needed
Relationship to item identification:
- Entries rely on item IDs and types exposed by the game’s item system
- Matching uses these identifiers to find suitable world objects
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
### ScavengerManager: Orchestration and Tracking
ScavengerManager coordinates the entire scavenging process:
- Scanning: enumerates nearby or visible items via EntityCollection
- Filtering: applies entry criteria (IDs, types, categories) to build candidate lists
- Prioritization: selects the most relevant candidate based on entry priority and other factors
- Tracking: maintains per-entry counts and determines when targets are met
- Execution: performs actions such as targeting or using skills to gather resources
Algorithm overview:
```mermaid
flowchart TD
Start(["Start Tick"]) --> Scan["Enumerate Items<br/>from EntityCollection"]
Scan --> BuildCandidates["Build Candidates per Entry<br/>by ID/Type/Category"]
BuildCandidates --> UpdateCounts["Update Collected Counts"]
UpdateCounts --> CheckTargets{"Any Targets Met?"}
CheckTargets --> |Yes| MarkComplete["Mark Entry Complete"]
CheckTargets --> |No| SelectCandidate["Select Best Candidate<br/>by Priority and Proximity"]
SelectCandidate --> ExecuteAction["Target/Use/Skill to Gather"]
ExecuteAction --> End(["End Tick"])
MarkComplete --> End
```
**Diagram sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
**Section sources**
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
### UI Integration: ScavengerTabViewModel and ScavengerTabControl
- ScavengerTabViewModel binds ScavengerEntry collections to the UI, exposes commands to add/remove/edit entries, and refreshes counts/status
- ScavengerTabControl hosts the UI and initializes the view model
User workflow:
- Add new entries with item identifiers and target quantities
- Adjust priorities to influence collection order
- Observe real-time counts and completion status
**Section sources**
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
### Item Identification System Integration
Scavenger relies on the game’s item identification system:
- Item IDs and types are primary matching keys
- Categories (ores, logs, herbs, general loot) map to item type groups
- Hue and property filters may refine matches where supported
This ensures accurate targeting across different shard implementations and item sets.
**Section sources**
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
### Example Scenarios
#### Basic Setup: Mining Copper Ore
- Create a ScavengerEntry for copper ore using its ID/type
- Set target quantity to your inventory capacity or desired amount
- Assign high priority to focus on copper before other materials
- Ensure category filter includes ores
#### Basic Setup: Collecting Wood from Trees
- Configure entry for logs or tree-related statics
- Use category filter for logs
- Set quantity based on crafting needs
- Lower priority than ores if you prefer to mine first
#### Basic Setup: Harvesting Herbs
- Configure entry for herb types
- Optionally constrain by hue if specific herb colors matter
- Set quantity and moderate priority
These examples demonstrate how entries translate into automated collection workflows.
[No sources needed since this section provides conceptual examples without analyzing specific files]
## Dependency Analysis
The following diagram shows key dependencies among Scavenger components and core UO abstractions:
```mermaid
classDiagram
class ScavengerEntry {
+Identifier
+Quantity
+Priority
+CategoryFilter
}
class ScavengerManager {
+Scan()
+Filter()
+Prioritize()
+TrackCounts()
+Execute()
}
class ScavengerTabViewModel {
+Entries
+Refresh()
+AddEntry()
+RemoveEntry()
}
class ScavengerTabControl {
+InitializeBindings()
}
class Item {
+ID
+Type
+Hue
}
class EntityCollection {
+Enumerate()
}
ScavengerTabViewModel --> ScavengerEntry : "manages"
ScavengerTabViewModel --> ScavengerManager : "delegates"
ScavengerTabControl --> ScavengerTabViewModel : "hosts"
ScavengerManager --> ScavengerEntry : "evaluates"
ScavengerManager --> EntityCollection : "reads"
ScavengerManager --> Item : "targets"
```
**Diagram sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
**Section sources**
- [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs)
- [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs)
- [ScavengerTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/ScavengerTabViewModel.cs)
- [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [EntityCollection.cs](file://ClassicAssist.Shared/UO/Objects/EntityCollection.cs)
## Performance Considerations
- Limit scan scope: Prefer local or filtered enumeration to reduce overhead
- Batch updates: Avoid excessive UI refreshes; coalesce count updates
- Prioritize efficiently: Precompute candidate lists per entry to minimize repeated filtering
- Throttle actions: Prevent spamming target/use calls; respect cooldowns and server limits
- Cache stable data: Reuse item metadata where possible to avoid redundant lookups
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- No matches found: Verify item IDs/types and category filters align with the shard’s item definitions
- Incorrect priority ordering: Adjust entry priorities to reflect desired collection sequence
- Count not updating: Ensure the manager is running and the UI is refreshing; check for errors in the manager loop
- Excessive targeting: Reduce scan frequency or increase minimum distance thresholds to avoid over-targeting
Validation references:
- Unit tests cover typical behaviors and edge cases for Scavenger functionality
**Section sources**
- [ScavengerTests.cs](file://ClassicAssist.Tests/Agents/ScavengerTests.cs)
## Conclusion
The Scavenger Agent in ClassicAssist.Avalonia provides a flexible and powerful framework for automated resource gathering. By configuring ScavengerEntry targets, leveraging category filters, and managing priorities, players can automate tasks such as mining ores, collecting wood, and harvesting herbs. The ScavengerManager orchestrates scanning, filtering, tracking, and execution, while the UI layers offer intuitive configuration and real-time feedback. Proper alignment with the game’s item identification system ensures reliable matching across different environments.
[No sources needed since this section summarizes without analyzing specific files]
@@ -0,0 +1,417 @@
# Buy Agents
<cite>
**Referenced Files in This Document**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorBuyTabControl.xaml](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [BuyAgentTests.cs](file://ClassicAssist.Tests/Agents/BuyAgentTests.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)
10. [Appendices](#appendices)
## Introduction
This document explains the Vendor Buy Agent system that automatically purchases items from NPCs based on configured shop lists and criteria. It covers data structures, selection algorithms, price monitoring, stock tracking, automatic restocking triggers, UI configuration, common buying scenarios, and error handling for insufficient funds, vendor inventory limitations, and transaction failures.
## Project Structure
The buy agent spans shared data models, network packet definitions, UI view models, and tests:
- Data models define buy rules and shop entries.
- Network packets model vendor interactions (opening vendor windows, requesting buys).
- UI components provide a tabbed interface to create and manage buy rules.
- Tests validate core behaviors.
```mermaid
graph TB
subgraph "Shared Data"
VBAE["VendorBuyAgentEntry.cs"]
SLE["ShopListEntry.cs"]
VSAE["VendorSellAgentEntry.cs"]
XYC["XYComparer.cs"]
end
subgraph "UI"
VM["VendorBuyTabViewModel.cs"]
XAMLCS["VendorBuyTabControl.xaml.cs"]
XAML["VendorBuyTabControl.xaml"]
end
subgraph "Network"
VB["VendorBuy.cs"]
CCP["ContainerContentsPacket.cs"]
CCU["ContainerContentUpdate.cs"]
UO["UseObject.cs"]
CMC["ContextMenuClick.cs"]
end
subgraph "Tests"
BAT["BuyAgentTests.cs"]
end
VM --> VBAE
VM --> SLE
VM --> VSAE
VM --> XYC
VM --> VB
VM --> CCP
VM --> CCU
VM --> UO
VM --> CMC
BAT --> VBAE
BAT --> SLE
```
**Diagram sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorBuyTabControl.xaml](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [BuyAgentTests.cs](file://ClassicAssist.Tests/Agents/BuyAgentTests.cs)
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorBuyTabControl.xaml](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [BuyAgentTests.cs](file://ClassicAssist.Tests/Agents/BuyAgentTests.cs)
## Core Components
- VendorBuyAgentEntry: Represents a single buy rule with item identifiers, quantity limits, price thresholds, vendor preferences, and state such as last purchase time or stock counters.
- ShopListEntry: Defines an entry within a vendor’s shop list including item properties, price, and availability indicators used by the agent to match and select items.
- VendorBuyTabViewModel: Binds the UI to buy rules, orchestrates scanning vendor inventories, applying selection criteria, and issuing purchase requests.
- VendorBuyTabControl: Hosts the Avalonia UI for creating/editing buy rules and displaying status.
- Network Packets: VendorBuy, ContainerContentsPacket, ContainerContentUpdate, UseObject, ContextMenuClick are used to open vendors, read shop contents, and request purchases.
Key responsibilities:
- Maintain and persist buy rules.
- Match vendor shop items against criteria.
- Enforce quantity caps and price monitoring.
- Trigger purchases when conditions are met.
- Handle errors and update UI state.
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorBuyTabControl.xaml](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
## Architecture Overview
The buy agent follows a pipeline:
- User configures buy rules via the UI.
- The agent periodically scans nearby vendors or reacts to vendor window events.
- It reads vendor shop contents using container-related packets.
- It applies selection algorithms (item matching, price checks, stock levels).
- It issues purchase requests through vendor buy packets.
- It updates internal state and UI feedback.
```mermaid
sequenceDiagram
participant UI as "VendorBuyTabControl"
participant VM as "VendorBuyTabViewModel"
participant Model as "VendorBuyAgentEntry / ShopListEntry"
participant Net as "Network Packets"
participant Game as "Game Server"
UI->>VM : "Create/Edit Buy Rule"
VM->>Model : "Persist rule"
VM->>Net : "Open vendor / Request shop contents"
Net-->>VM : "ContainerContentsPacket"
VM->>VM : "Match items against criteria<br/>Check price and stock"
alt "Conditions met"
VM->>Net : "VendorBuy request"
Net-->>Game : "Purchase attempt"
Game-->>VM : "Result (success/failure)"
VM->>Model : "Update counters and timestamps"
VM->>UI : "Refresh status"
else "No match or failure"
VM->>Model : "Mark skipped or retry later"
VM->>UI : "Show reason"
end
```
**Diagram sources**
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
## Detailed Component Analysis
### VendorBuyAgentEntry
Purpose:
- Encapsulates a single buy rule with all necessary parameters for automated purchasing.
- Tracks runtime state like last purchase timestamp, current stock count, and flags for enabling/disabling the rule.
Key aspects:
- Item identification fields for matching vendor shop entries.
- Quantity constraints (min/max per cycle or total).
- Price threshold controls (max price, optional average price tracking).
- Vendor preference filters (e.g., specific vendor types or locations).
- State fields for cooldowns, retries, and logs.
Complexity:
- O(1) access to rule fields; evaluation cost depends on matching logic in the ViewModel.
Error handling:
- Validates numeric ranges and ensures required fields are set before activation.
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
### ShopListEntry
Purpose:
- Represents an item as it appears in a vendor’s shop list.
- Provides attributes needed for matching and decision-making (price, quantity available, item IDs, etc.).
Key aspects:
- Fields for item identity and properties.
- Price and stock information parsed from vendor shop packets.
- Comparison helpers to sort or filter shop items.
Complexity:
- Matching is typically linear over the number of shop items.
**Section sources**
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
### VendorBuyTabViewModel
Responsibilities:
- Loads and persists buy rules.
- Orchestrates vendor discovery and shop scanning.
- Applies selection algorithms and enforces constraints.
- Issues purchase requests and handles responses.
- Updates UI bindings for real-time feedback.
Selection algorithm overview:
- Iterate enabled rules.
- For each rule, scan vendor shop entries.
- Match items by ID and other criteria.
- Check price against thresholds.
- Verify stock availability and quantity limits.
- Select best candidate (e.g., lowest price among matches).
- Execute purchase if all conditions pass.
```mermaid
flowchart TD
Start(["Start Cycle"]) --> LoadRules["Load Enabled Rules"]
LoadRules --> ForEachRule{"Next Rule?"}
ForEachRule --> |No| End(["End Cycle"])
ForEachRule --> |Yes| ScanVendor["Scan Vendor Shop Entries"]
ScanVendor --> MatchItems["Match Items Against Criteria"]
MatchItems --> HasMatch{"Any Matches?"}
HasMatch --> |No| NextRule["Next Rule"]
HasMatch --> CheckPrice["Check Price Thresholds"]
CheckPrice --> PriceOK{"Within Budget?"}
PriceOK --> |No| NextRule
PriceOK --> CheckStock["Check Stock and Quantity Limits"]
CheckStock --> StockOK{"Sufficient Stock?"}
StockOK --> |No| NextRule
StockOK --> Purchase["Issue Vendor Buy Request"]
Purchase --> UpdateState["Update Rule State and UI"]
UpdateState --> NextRule
NextRule --> ForEachRule
```
**Diagram sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
**Section sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
### UI Interface (VendorBuyTabControl)
Features:
- Create, edit, enable/disable buy rules.
- Configure quantity limits and vendor preferences.
- Display live status (last purchase time, remaining stock, errors).
- Bindings to ViewModel for reactive updates.
User workflow:
- Add a new rule and specify target items and constraints.
- Save and enable the rule.
- Monitor auto-purchases and adjust thresholds as needed.
**Section sources**
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorBuyTabControl.xaml](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml)
### Network Interactions
- Opening vendor windows and reading shop contents rely on container-related packets.
- Purchase requests use vendor buy packets.
- Context menu actions may be used to initiate vendor interactions.
```mermaid
classDiagram
class VendorBuy {
+vendor_id
+item_id
+quantity
}
class ContainerContentsPacket {
+container_id
+entries[]
}
class ContainerContentUpdate {
+container_id
+changes[]
}
class UseObject {
+target_id
}
class ContextMenuClick {
+menu_id
+button_id
}
VendorBuyTabViewModel --> VendorBuy : "issues"
VendorBuyTabViewModel --> ContainerContentsPacket : "reads shop"
VendorBuyTabViewModel --> ContainerContentUpdate : "reacts to changes"
VendorBuyTabViewModel --> UseObject : "opens vendor"
VendorBuyTabViewModel --> ContextMenuClick : "initiates interaction"
```
**Diagram sources**
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
**Section sources**
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
## Dependency Analysis
- VendorBuyTabViewModel depends on:
- VendorBuyAgentEntry and ShopListEntry for rule data and shop item representation.
- Network packets for vendor operations and shop content parsing.
- UI components for user input and display.
- VendorSellAgentEntry and XYComparer are related but not strictly required for buy logic; they support broader vendor functionality and comparisons.
```mermaid
graph LR
VM["VendorBuyTabViewModel.cs"] --> VBAE["VendorBuyAgentEntry.cs"]
VM --> SLE["ShopListEntry.cs"]
VM --> VB["VendorBuy.cs"]
VM --> CCP["ContainerContentsPacket.cs"]
VM --> CCU["ContainerContentUpdate.cs"]
VM --> UO["UseObject.cs"]
VM --> CMC["ContextMenuClick.cs"]
VM -. optional .-> VSAE["VendorSellAgentEntry.cs"]
VM -. optional .-> XYC["XYComparer.cs"]
```
**Diagram sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
**Section sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [ContainerContentsPacket.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentsPacket.cs)
- [ContainerContentUpdate.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContainerContentUpdate.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
## Performance Considerations
- Minimize repeated vendor scans by caching shop contents until updates arrive via container updates.
- Prefer early exits in matching loops when criteria clearly fail.
- Batch purchase requests where possible to reduce network overhead.
- Debounce UI updates to avoid excessive redraws during bulk operations.
- Use efficient comparators for sorting shop items by price or relevance.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Insufficient funds:
- Ensure budget thresholds are set appropriately.
- Review recent transactions and adjust max price or quantity limits.
- Vendor inventory limitations:
- Check stock counters and vendor refresh cycles.
- Increase wait intervals between scans if vendors replenish slowly.
- Transaction failures:
- Validate vendor interaction sequence (open vendor, read shop, then buy).
- Confirm correct item IDs and quantities in buy rules.
- Inspect UI error messages and logs for server-side rejection reasons.
Operational tips:
- Temporarily disable problematic rules to isolate issues.
- Reduce rule complexity (fewer criteria) to verify baseline behavior.
- Monitor last purchase timestamps to detect stalls.
**Section sources**
- [BuyAgentTests.cs](file://ClassicAssist.Tests/Agents/BuyAgentTests.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
## Conclusion
The Vendor Buy Agent automates NPC purchases by combining configurable rules, robust selection algorithms, and precise network interactions. With clear UI controls and comprehensive error handling, it supports diverse scenarios such as bulk resource gathering, equipment upgrades, and consumable management. Properly tuning price thresholds, stock monitoring, and vendor preferences yields reliable, hands-free purchasing.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
### Common Buying Scenarios
- Bulk resource gathering:
- Set higher quantity limits and moderate price thresholds.
- Enable periodic scans to keep inventory stocked.
- Equipment upgrades:
- Target specific item IDs with strict quality criteria.
- Limit purchases to one per cycle to avoid overspending.
- Consumable management:
- Track minimum stock levels and trigger restocks automatically.
- Use price averaging to smooth out market fluctuations.
[No sources needed since this section provides general guidance]
@@ -0,0 +1,426 @@
# Price Tracking & Analysis
<cite>
**Referenced Files in This Document**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.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)
10. [Appendices](#appendices)
## Introduction
This document explains the Price Tracking and Analysis system within vendor management. It covers how NPC prices are monitored, historical pricing data is tracked, and cost analysis supports trading decisions. It also documents the XYComparer utility for price comparisons, price threshold configurations, market trend analysis, best vendor selection, price alerting, profit margin calculations, integration with buy and sell agents, optimization strategies (bulk purchase timing and market speculation), data storage considerations, performance characteristics for large datasets, and export capabilities for financial analysis.
## Project Structure
The price tracking and analysis features are implemented across shared data models, UI view models, and network packet handling:
- Data models define entries for shop listings, sell lists, and agent-specific configuration for buying and selling.
- A dedicated comparer utility enables consistent ordering and comparison of items by key attributes such as name and price.
- UI tabs and view models expose controls and bindings to configure thresholds, display trends, and trigger actions.
- Network handlers integrate with incoming vendor packets to capture live pricing updates.
```mermaid
graph TB
subgraph "Shared Data"
VBA["VendorBuyAgentEntry.cs"]
VSA["VendorSellAgentEntry.cs"]
SLE["ShopListEntry.cs"]
SEL["SellListEntry.cs"]
XYC["XYComparer.cs"]
end
subgraph "UI"
VBTV["VendorBuyTabViewModel.cs"]
VSTV["VendorSellTabViewModel.cs"]
VBTC["VendorBuyTabControl.xaml.cs"]
VSTC["VendorSellTabControl.xaml.cs"]
end
subgraph "Network"
IPH["IncomingPacketHandlers.cs"]
VBP["VendorBuy.cs"]
end
VBA --> VBTV
VSA --> VSTV
SLE --> VBTV
SEL --> VSTV
XYC --> VBTV
XYC --> VSTV
IPH --> VBP
VBP --> VBTV
VBP --> VSTV
```
**Diagram sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Aavonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
## Core Components
- Shop listing entry: Represents an item available from a vendor with properties used for price tracking and filtering.
- Sell list entry: Represents an item configured for automated selling with thresholds and preferences.
- Buy agent entry: Holds configuration for automated purchasing behavior, including thresholds and target vendors.
- Sell agent entry: Holds configuration for automated selling behavior, including thresholds and target vendors.
- XYComparer: Provides consistent comparison logic for sorting and ranking items by multiple criteria (e.g., name, price).
- UI View Models: VendorBuyTabViewModel and VendorSellTabViewModel coordinate user interactions, thresholds, and display of price analytics.
- Network Integration: IncomingPacketHandlers and VendorBuy packet types feed live vendor pricing into the system.
Key responsibilities:
- Capture and store current and historical prices.
- Compare and rank vendors based on price and other criteria.
- Apply thresholds to trigger alerts or automated actions.
- Compute profit margins and support decision-making.
**Section sources**
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
## Architecture Overview
The system integrates real-time vendor pricing via network packets, persists and analyzes price history, and exposes controls for thresholds and automation. The flow below shows how incoming vendor data is processed and consumed by UI and automation components.
```mermaid
sequenceDiagram
participant Game as "Game Client"
participant Net as "IncomingPacketHandlers.cs"
participant Packet as "VendorBuy.cs"
participant VM as "VendorBuyTabViewModel.cs / VendorSellTabViewModel.cs"
participant Model as "ShopListEntry.cs / SellListEntry.cs"
participant Agent as "VendorBuyAgentEntry.cs / VendorSellAgentEntry.cs"
participant Comp as "XYComparer.cs"
Game->>Net : "Vendor price update"
Net->>Packet : "Parse VendorBuy packet"
Packet-->>VM : "Item price data"
VM->>Model : "Update current price and history"
VM->>Agent : "Evaluate thresholds and rules"
VM->>Comp : "Compare vendors and sort candidates"
VM-->>Game : "Trigger buy/sell actions if conditions met"
```
**Diagram sources**
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
## Detailed Component Analysis
### Shop Listing Entry
Purpose:
- Captures item details and pricing information from vendor listings.
- Supports filtering and historical tracking by maintaining fields for current and past prices.
Key aspects:
- Fields for item identification and price values.
- Methods or properties that enable updating and querying price history.
- Compatibility with comparers for sorting and ranking.
Use cases:
- Displaying current vendor prices.
- Computing average, min, max over time windows.
- Feeding trend analysis and alerting logic.
**Section sources**
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
### Sell List Entry
Purpose:
- Defines items intended for automated selling with configurable thresholds and preferences.
Key aspects:
- Thresholds for minimum sell price or profit margin.
- Flags or options controlling when to sell (e.g., immediate vs. delayed).
- Integration with sell agent logic to execute sales.
Use cases:
- Automated liquidation of inventory above configured thresholds.
- Profit margin enforcement before selling.
- Bulk sell operations guided by price trends.
**Section sources**
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
### Buy Agent Entry
Purpose:
- Configures automated purchasing behavior, including target vendors and price constraints.
Key aspects:
- Thresholds for maximum buy price.
- Best vendor selection criteria using comparers.
- Rules for bulk purchases and timing.
Use cases:
- Selecting the lowest-cost vendor meeting quality constraints.
- Triggering purchases when prices drop below configured levels.
- Coordinating with market trend analysis to optimize timing.
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
### Sell Agent Entry
Purpose:
- Configures automated selling behavior, including thresholds and execution policies.
Key aspects:
- Minimum acceptable sell price or profit margin.
- Timing strategies (immediate vs. wait for better price).
- Integration with sell list entries and price history.
Use cases:
- Selling at optimal times based on historical highs.
- Enforcing profit targets before executing sales.
- Managing risk by avoiding sells during downward trends.
**Section sources**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
### XYComparer Utility
Purpose:
- Provides consistent comparison logic for items, enabling reliable sorting and ranking across multiple criteria.
Key aspects:
- Comparison by name, then by price or other attributes.
- Stable ordering to ensure deterministic results.
- Reusable across buy and sell workflows.
Use cases:
- Ranking vendors by price for best vendor selection.
- Sorting historical price snapshots for trend visualization.
- Deterministic ordering for exports and reports.
**Section sources**
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
### UI Tabs and View Models
Purpose:
- Expose configuration and analytics for price tracking and automation.
Key aspects:
- VendorBuyTabViewModel coordinates buy-related thresholds, vendor selection, and trend displays.
- VendorSellTabViewModel coordinates sell-related thresholds, profit margins, and alerting.
- Tab control code-behinds manage UI lifecycle and binding contexts.
Use cases:
- Setting price thresholds and viewing alerts.
- Analyzing trends and selecting optimal vendors.
- Triggering manual or automated buy/sell actions.
**Section sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
### Network Integration
Purpose:
- Captures live vendor pricing updates and feeds them into the system.
Key aspects:
- IncomingPacketHandlers processes vendor-related packets.
- VendorBuy packet type carries item price data.
- Updates propagate to view models and data entries.
Use cases:
- Real-time price monitoring.
- Immediate threshold evaluation and alerting.
- Updating historical records for trend analysis.
**Section sources**
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
### Price Alerting Flow
```mermaid
flowchart TD
Start(["Price Update Received"]) --> CheckThresholds["Check Buy/Sell Thresholds"]
CheckThresholds --> BelowBuy{"Below Buy Threshold?"}
BelowBuy --> |Yes| AlertBuy["Generate Buy Alert"]
BelowBuy --> |No| AboveSell{"Above Sell Threshold?"}
AboveSell --> |Yes| AlertSell["Generate Sell Alert"]
AboveSell --> |No| NoAction["No Action"]
AlertBuy --> EvaluateRules["Apply Automation Rules"]
AlertSell --> EvaluateRules
EvaluateRules --> ExecuteAction["Execute Buy/Sell or Notify User"]
NoAction --> End(["End"])
ExecuteAction --> End
```
[No sources needed since this diagram shows conceptual workflow, not actual code structure]
## Dependency Analysis
The following diagram maps dependencies among core components involved in price tracking and analysis.
```mermaid
classDiagram
class ShopListEntry {
+item_id
+price
+history
}
class SellListEntry {
+item_id
+sell_threshold
+profit_margin
}
class VendorBuyAgentEntry {
+buy_threshold
+best_vendor_strategy
}
class VendorSellAgentEntry {
+sell_threshold
+timing_strategy
}
class XYComparer {
+compare(itemA, itemB) int
}
class VendorBuyTabViewModel {
+updatePrices()
+evaluateBuy()
+getBestVendor()
}
class VendorSellTabViewModel {
+updatePrices()
+evaluateSell()
+computeMargin()
}
class IncomingPacketHandlers {
+handleVendorBuy(packet)
}
class VendorBuy {
+item_id
+price
}
VendorBuyTabViewModel --> ShopListEntry : "reads/writes"
VendorSellTabViewModel --> SellListEntry : "reads/writes"
VendorBuyTabViewModel --> VendorBuyAgentEntry : "uses config"
VendorSellTabViewModel --> VendorSellAgentEntry : "uses config"
VendorBuyTabViewModel --> XYComparer : "sort/rank"
VendorSellTabViewModel --> XYComparer : "sort/rank"
IncomingPacketHandlers --> VendorBuy : "parses"
IncomingPacketHandlers --> VendorBuyTabViewModel : "updates"
IncomingPacketHandlers --> VendorSellTabViewModel : "updates"
```
**Diagram sources**
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
**Section sources**
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
## Performance Considerations
- Efficient Comparisons: Use XYComparer consistently to avoid repeated custom sorting logic and ensure stable orderings.
- History Management: Implement bounded buffers or rolling windows for price history to limit memory growth and maintain query performance.
- Batch Updates: Coalesce frequent price updates into batched processing to reduce UI churn and computation overhead.
- Indexing: Maintain indexes on frequently queried fields (e.g., item_id, timestamp) to speed up trend queries and exports.
- Lazy Loading: Load detailed price histories on demand rather than upfront to improve startup and responsiveness.
- Concurrency: Ensure thread-safe access to shared price data structures; use queues or locks where necessary to prevent race conditions.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Missing price updates: Verify IncomingPacketHandlers is wired to VendorBuy packets and that UI view models receive updates.
- Incorrect vendor ranking: Confirm XYComparer is applied consistently and that comparison keys match expected semantics.
- Thresholds not triggering: Check configuration in VendorBuyAgentEntry and VendorSellAgentEntry, and ensure thresholds are evaluated after each price update.
- High memory usage: Inspect price history retention policies and implement rolling windows or periodic pruning.
- Export failures: Validate data integrity and schema consistency before exporting; handle missing fields gracefully.
**Section sources**
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
## Conclusion
The Price Tracking and Analysis system integrates live vendor pricing with robust data models, comparers, and UI-driven configuration. It supports best vendor selection, price alerting, profit margin calculations, and automation through buy and sell agents. By applying efficient comparison, careful history management, and clear threshold rules, users can make informed trading decisions, optimize bulk purchases, and engage in market speculation with confidence.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
### Price Optimization Strategies
- Best Vendor Selection: Rank vendors using XYComparer and select the lowest-cost option meeting quality constraints.
- Bulk Purchase Timing: Accumulate demand and execute purchases when prices fall below configured thresholds or when trend indicators suggest favorable conditions.
- Market Speculation Tools: Monitor historical highs/lows and volatility; set dynamic thresholds that adapt to recent trends.
[No sources needed since this section provides general guidance]
### Data Storage for Price History
- Store per-item price snapshots with timestamps.
- Retain rolling windows to balance detail and performance.
- Provide APIs for querying averages, minima, maxima, and trend metrics.
[No sources needed since this section provides general guidance]
### Export Capabilities for Financial Analysis
- Export current prices and historical series to CSV or similar formats.
- Include metadata such as item identifiers, vendor IDs, timestamps, and computed metrics (e.g., moving averages).
- Ensure deterministic ordering using XYComparer for reproducible outputs.
[No sources needed since this section provides general guidance]
@@ -0,0 +1,375 @@
# Sell Agents
<cite>
**Referenced Files in This Document**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellTests.cs](file://ClassicAssist.Tests/Agents/SellAgentTests.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)
10. [Appendices](#appendices)
## Introduction
This document explains the Vendor Sell Agent system that automatically sells unwanted items to NPCs based on configurable sell lists and conditions. It covers the data structures, filtering logic, UI configuration, profit optimization features, price comparison across vendors, inventory cleanup strategies, and practical workflows such as junk disposal, loot processing, and maintenance routines. It also addresses considerations like vendor reputation effects, selling restrictions, and market value fluctuations.
## Project Structure
The Vendor Sell Agent spans shared data models, UI view models, and tests:
- Shared data models define agent entries, sell list entries, and related helpers.
- Avalonia UI provides the tab control for managing sell rules.
- Tests validate behavior and edge cases.
```mermaid
graph TB
subgraph "Shared Data"
VSAE["VendorSellAgentEntry.cs"]
SLE["SellListEntry.cs"]
VBAE["VendorBuyAgentEntry.cs"]
SLEntry["ShopListEntry.cs"]
XYC["XYComparer.cs"]
end
subgraph "UI (Avalonia)"
VSTabVM["VendorSellTabViewModel.cs"]
VSTabCtrl["VendorSellTabControl.xaml.cs"]
end
subgraph "Tests"
SAT["SellAgentTests.cs"]
end
VSTabVM --> VSAE
VSTabVM --> SLE
VSTabCtrl --> VSTabVM
SAT --> VSAE
SAT --> SLE
```
**Diagram sources**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [SellAgentTests.cs](file://ClassicAssist.Tests/Agents/SellAgentTests.cs)
**Section sources**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [SellAgentTests.cs](file://ClassicAssist.Tests/Agents/SellAgentTests.cs)
## Core Components
- VendorSellAgentEntry: Represents a configured sell agent instance with settings controlling which items are sold, thresholds, and behaviors.
- SellListEntry: Defines individual sell rules including item criteria, minimum value, and exclusion flags.
- VendorSellTabViewModel: Binds UI controls to agent configuration, exposes commands to add/remove/edit rules, and orchestrates selling operations.
- VendorSellTabControl: Hosts the UI surface for managing sell rules and triggers actions from the ViewModel.
- Supporting types: ShopListEntry and VendorBuyAgentEntry provide context for vendor interactions; XYComparer supports spatial comparisons when needed.
Key responsibilities:
- Maintain collections of sell rules and agent options.
- Evaluate inventory items against rules and thresholds.
- Execute sell actions through vendor interfaces.
- Persist and load configurations via the UI.
**Section sources**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
## Architecture Overview
The sell flow is driven by the ViewModel, which reads agent configuration and applies filtering logic to inventory items. When an item matches a rule and meets thresholds, the agent initiates a sale through the vendor interface.
```mermaid
sequenceDiagram
participant User as "User"
participant UI as "VendorSellTabControl"
participant VM as "VendorSellTabViewModel"
participant Agent as "VendorSellAgentEntry"
participant Rule as "SellListEntry"
participant Inv as "Inventory"
participant Vendor as "Vendor Interface"
User->>UI : Open Sell Rules Tab
UI->>VM : Load Configuration
VM->>Agent : Read Settings and Rules
User->>UI : Trigger Sell Action
UI->>VM : Execute Sell
VM->>Inv : Enumerate Items
loop For each Item
VM->>Rule : Check Match and Thresholds
alt Matches Rule and Meets Min Value
VM->>Vendor : Sell Item
Vendor-->>VM : Result
else Does Not Match or Below Threshold
VM->>VM : Skip Item
end
end
VM-->>UI : Update Status and Summary
```
**Diagram sources**
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
## Detailed Component Analysis
### VendorSellAgentEntry
Purpose:
- Holds agent-level configuration such as enabled state, default thresholds, and global filters.
- Provides accessors for rule evaluation and action execution.
Key aspects:
- Global enable/disable toggle.
- Default minimum value threshold if not specified per rule.
- Flags to include/exclude categories or specific properties.
- Integration points for vendor selection and transaction handling.
Complexity:
- O(1) accessors for settings.
- Rule iteration cost depends on number of rules.
Optimization opportunities:
- Cache frequently accessed metadata (e.g., item categories).
- Short-circuit evaluation when global disable is set.
Error handling:
- Validate configuration on load.
- Log invalid rules and skip them during evaluation.
**Section sources**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
### SellListEntry
Purpose:
- Encapsulates a single sell rule with match criteria and thresholds.
Attributes typically include:
- Item identifier or pattern matching fields.
- Minimum value threshold override.
- Exclusion flags for valuable or special items.
- Optional category or property constraints.
Evaluation logic:
- Compare item attributes against rule fields.
- Apply minimum value check using either rule-specific or agent-wide threshold.
- Respect exclusion flags to protect high-value items.
Complexity:
- Per-item evaluation is O(R) where R is number of active rules.
- Sorting/comparison helpers may be used for ordering candidates.
Optimization opportunities:
- Precompute normalized identifiers for faster matching.
- Group rules by category to reduce comparisons.
Error handling:
- Ignore malformed rules gracefully.
- Provide clear diagnostics for unmatched expectations.
**Section sources**
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
### VendorSellTabViewModel
Purpose:
- Binds UI to agent configuration and rules.
- Exposes commands to add, edit, remove, and reorder rules.
- Orchestrates selling operations and updates UI state.
Responsibilities:
- Initialize and persist configuration.
- Manage observable collections of rules.
- Handle user interactions and validation feedback.
- Coordinate with VendorSellAgentEntry to execute sells.
Integration points:
- VendorSellTabControl for rendering and input.
- Underlying vendor interfaces for transactions.
Error handling:
- Validate inputs before saving.
- Report failures during selling with actionable messages.
**Section sources**
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
### VendorSellTabControl
Purpose:
- Hosts the XAML layout and code-behind for the sell rules tab.
- Wires up events and delegates to the ViewModel.
Responsibilities:
- Display rule lists and forms.
- Trigger ViewModel commands.
- Reflect status changes and summaries.
Error handling:
- Ensure UI remains responsive during long-running operations.
- Surface errors to users without crashing.
**Section sources**
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
### Supporting Types
- ShopListEntry: Represents shop-related data used in vendor contexts.
- VendorBuyAgentEntry: Related buy agent entry providing symmetry for purchase flows.
- XYComparer: Utility for comparing coordinates or positions when relevant to vendor proximity.
Usage:
- These types support vendor interaction and spatial decisions but are not core to sell rule evaluation.
**Section sources**
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
### Class Diagram
```mermaid
classDiagram
class VendorSellAgentEntry {
+bool Enabled
+decimal DefaultMinValue
+IEnumerable~SellListEntry~ Rules
+Evaluate(item) bool
+ExecuteSell(item) void
}
class SellListEntry {
+string ItemIdOrPattern
+decimal? MinValueOverride
+bool ExcludeValuable
+Match(item) bool
}
class VendorSellTabViewModel {
+ObservableCollection~SellListEntry~ Rules
+void AddRule()
+void RemoveRule(rule)
+void SaveConfiguration()
+void ExecuteSell()
}
class VendorSellTabControl {
+InitializeComponent()
+OnSellClicked()
}
VendorSellTabViewModel --> VendorSellAgentEntry : "uses"
VendorSellTabViewModel --> SellListEntry : "manages"
VendorSellTabControl --> VendorSellTabViewModel : "binds to"
```
**Diagram sources**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
## Dependency Analysis
- VendorSellTabViewModel depends on VendorSellAgentEntry and SellListEntry for configuration and evaluation.
- VendorSellTabControl depends on VendorSellTabViewModel for behavior.
- Tests depend on both data models and ViewModel to assert correctness.
```mermaid
graph LR
VSTabCtrl["VendorSellTabControl.xaml.cs"] --> VSTabVM["VendorSellTabViewModel.cs"]
VSTabVM --> VSAE["VendorSellAgentEntry.cs"]
VSTabVM --> SLE["SellListEntry.cs"]
SAT["SellAgentTests.cs"] --> VSAE
SAT --> SLE
```
**Diagram sources**
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [SellAgentTests.cs](file://ClassicAssist.Tests/Agents/SellAgentTests.cs)
**Section sources**
- [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [SellAgentTests.cs](file://ClassicAssist.Tests/Agents/SellAgentTests.cs)
## Performance Considerations
- Rule evaluation complexity scales with the number of active rules; prefer concise patterns and categorization to minimize comparisons.
- Use short-circuiting: disable the agent globally when not needed to avoid unnecessary enumeration.
- Cache expensive lookups (e.g., item metadata) to reduce repeated work.
- Batch sell operations where possible to reduce vendor interaction overhead.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- No items sold:
- Verify agent is enabled and at least one rule exists.
- Confirm minimum value thresholds are not too high.
- Check exclusion flags that might protect items.
- Incorrect items sold:
- Review rule patterns and exclusions.
- Ensure item identifiers or categories match expected values.
- UI not updating:
- Confirm bindings are correct in the ViewModel.
- Check for exceptions in command handlers.
- Vendor errors:
- Inspect logs for transaction failures.
- Validate vendor availability and reputation requirements.
Validation and logging:
- The ViewModel should validate inputs and report errors clearly.
- Tests can help reproduce and isolate issues.
**Section sources**
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [SellAgentTests.cs](file://ClassicAssist.Tests/Agents/SellAgentTests.cs)
## Conclusion
The Vendor Sell Agent system provides a flexible, configurable approach to automating item sales to NPCs. By combining structured sell rules, thresholds, and exclusion logic, it enables efficient inventory cleanup while protecting valuable items. The UI facilitates easy management of rules and thresholds, and tests ensure reliability. With careful tuning of rules and thresholds, players can optimize profits and maintain streamlined inventories.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
### Practical Examples
- Junk item disposal:
- Create rules targeting low-value junk categories with minimal thresholds.
- Exclude any quest or unique items via exclusion flags.
- Loot processing:
- After combat, run the sell agent to quickly offload unneeded loot.
- Use category-based rules to handle common drops efficiently.
- Inventory maintenance:
- Schedule periodic runs to keep backpacks organized.
- Combine with other agents (e.g., organizer) for comprehensive management.
[No sources needed since this section provides general guidance]
### Profit Optimization and Price Comparison
- Configure minimum value thresholds to avoid selling undervalued items.
- Compare prices across multiple vendors by selecting the best option when available.
- Monitor market fluctuations and adjust thresholds accordingly.
[No sources needed since this section provides general guidance]
### Vendor Reputation and Selling Restrictions
- Some vendors may have reputation requirements or restricted selling capabilities.
- Ensure the selected vendor is accessible and authorized for the intended sales.
- Handle errors gracefully when restrictions prevent a sale.
[No sources needed since this section provides general guidance]
@@ -0,0 +1,448 @@
# Vendor Management
<cite>
**Referenced Files in This Document**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
- [VendorSellTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.axaml.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.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
This document explains the Vendor Management system in ClassicAssist.Avalonia, focusing on automated trading agents that handle buying and selling operations with NPCs. It covers the data structures for buy/sell entries, shop list management, transaction automation, UI components for configuration, price monitoring, stock tracking, vendor interface integration, item validation, currency management, and common trading scenarios such as bulk purchasing, profit maximization, and inventory restocking. Error handling for insufficient funds, vendor limitations, and network connectivity issues is also addressed.
## Project Structure
The Vendor Management feature spans shared data models, view models, Avalonia UI controls, and UO networking packets:
- Data models define agent entries and shop lists for buy/sell operations.
- View models provide state and commands to configure and run trades.
- Avalonia tabs host the user interfaces for configuring buy/sell lists and monitoring transactions.
- Networking packets encapsulate vendor buy requests sent to the game server.
```mermaid
graph TB
subgraph "Shared Models"
VBAE["VendorBuyAgentEntry"]
VSAE["VendorSellAgentEntry"]
SLE["ShopListEntry"]
SLSE["SellListEntry"]
XYC["XYComparer"]
end
subgraph "UI ViewModels"
VBVM["VendorBuyTabViewModel"]
VSVM["VendorSellTabViewModel"]
end
subgraph "Avalonia Views"
VBTAB["VendorBuyTabControl"]
VSTAB["VendorSellTabControl"]
end
subgraph "Networking"
VBP["VendorBuy Packet"]
end
VBAE --> VBVM
VSAE --> VSVM
SLE --> VBVM
SLSE --> VSVM
VBTAB --> VBVM
VSTAB --> VSVM
VBVM --> VBP
```
**Diagram sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
- [VendorSellTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.axaml.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
- [VendorSellTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.axaml.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
## Core Components
- VendorBuyAgentEntry: Represents a single buy rule or entry used by the buy agent to decide what to purchase from vendors.
- VendorSellAgentEntry: Represents a single sell rule or entry used by the sell agent to decide what to sell to vendors.
- ShopListEntry: Defines an item listing within a vendor’s shop catalog, including identifiers and pricing metadata.
- SellListEntry: Defines an item listing for the player’s sell queue, including quantities and target prices.
- XYComparer: Utility comparer used for sorting or ordering related to coordinates or indices (e.g., vendor positioning or list order).
These types form the backbone of the automated trading logic and are consumed by the UI view models to present and control buy/sell workflows.
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
## Architecture Overview
The Vendor Management architecture follows a layered approach:
- Data layer: Agent entries and shop/sell list entries model trade rules and catalogs.
- Presentation layer: Avalonia tabs host UI for configuration and monitoring.
- ViewModel layer: View models coordinate user actions, manage state, and orchestrate transactions.
- Network layer: Vendor buy packet sends purchase requests to the server.
```mermaid
sequenceDiagram
participant User as "User"
participant BuyTab as "VendorBuyTabControl"
participant VM as "VendorBuyTabViewModel"
participant Model as "VendorBuyAgentEntry / ShopListEntry"
participant Net as "VendorBuy Packet"
User->>BuyTab : Configure buy list and start
BuyTab->>VM : Bind and invoke Start()
VM->>Model : Resolve items and prices
VM->>Net : Send VendorBuy request(s)
Net-->>VM : Server response (success/failure)
VM-->>BuyTab : Update status, stock, and logs
```
**Diagram sources**
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
## Detailed Component Analysis
### VendorBuyAgentEntry
Purpose:
- Encapsulates a buy rule for the automated buy agent.
- Typically includes item identification, desired quantity, maximum price, and optional filters.
Key responsibilities:
- Matching against available shop items.
- Enforcing price caps and quantity limits.
- Integrating with stock checks before issuing purchases.
Common usage:
- Populated via UI configuration.
- Iterated by the buy workflow to generate purchase orders.
**Section sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
### VendorSellAgentEntry
Purpose:
- Encapsulates a sell rule for the automated sell agent.
- Typically includes item identification, minimum sell price, and quantity constraints.
Key responsibilities:
- Matching against vendor buyback prices.
- Ensuring profitability thresholds.
- Coordinating with inventory availability.
Common usage:
- Configured through the sell tab UI.
- Used by the sell workflow to propose sales.
**Section sources**
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
### ShopListEntry
Purpose:
- Represents an item offered by a vendor in their shop catalog.
- Contains fields for item ID, name, price, and possibly stock information.
Key responsibilities:
- Providing a normalized representation of vendor offerings.
- Supporting filtering and sorting by price or availability.
Integration points:
- Consumed by the buy agent to match against VendorBuyAgentEntry rules.
- Used by the UI to display shop contents and current prices.
**Section sources**
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
### SellListEntry
Purpose:
- Represents an item queued for sale to a vendor.
- Includes item identification, quantity, and target price.
Key responsibilities:
- Tracking pending sells and completed transactions.
- Enforcing minimum price constraints and quantity limits.
Integration points:
- Managed by the sell workflow and UI.
- Updated based on vendor buyback prices and inventory changes.
**Section sources**
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
### XYComparer
Purpose:
- Utility comparer for ordering elements by X/Y-like properties or indices.
- Often used to sort vendor positions or list entries deterministically.
Key responsibilities:
- Providing consistent ordering for collections.
- Supporting UI rendering stability and predictable processing order.
**Section sources**
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
### VendorBuyTabViewModel
Responsibilities:
- Binds to VendorBuyTabControl and exposes buy list state.
- Manages adding/removing VendorBuyAgentEntry items.
- Orchestrates buy operations using ShopListEntry data.
- Monitors stock levels and updates UI accordingly.
- Handles errors such as insufficient funds or vendor limits.
Notable behaviors:
- Validates entries before starting trades.
- Queues and executes purchases while respecting price caps.
- Updates progress indicators and logs.
**Section sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
### VendorSellTabViewModel
Responsibilities:
- Binds to VendorSellTabControl and exposes sell list state.
- Manages adding/removing VendorSellAgentEntry items.
- Orchestrates sell operations using SellListEntry data.
- Tracks vendor buyback prices and enforces minimum profit thresholds.
- Reports completion and error states.
Notable behaviors:
- Validates sell entries prior to execution.
- Coordinates with inventory and vendor constraints.
- Provides feedback on successful and failed sales.
**Section sources**
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
### VendorBuyTabControl (Avalonia)
Responsibilities:
- Hosts the buy configuration UI.
- Binds to VendorBuyTabViewModel for two-way data binding.
- Presents shop listings, stock counts, and transaction logs.
Interaction flow:
- User edits buy rules and triggers automation.
- ViewModel processes rules and interacts with network layer.
- UI reflects real-time status and results.
**Section sources**
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
### VendorSellTabControl (Avalonia)
Responsibilities:
- Hosts the sell configuration UI.
- Binds to VendorSellTabViewModel for two-way data binding.
- Displays sell queues, prices, and outcomes.
Interaction flow:
- User configures sell rules and starts automation.
- ViewModel validates and executes sales.
- UI updates with progress and logs.
**Section sources**
- [VendorSellTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.axaml.cs)
### VendorBuy Packet
Purpose:
- Encapsulates the vendor buy request payload sent to the server.
- Carries item IDs and quantities for purchase.
Usage:
- Constructed by the buy workflow when a valid purchase decision is made.
- Sent over the network; responses update stock and currency balances.
**Section sources**
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
#### Class Diagram: Vendor Data Model
```mermaid
classDiagram
class VendorBuyAgentEntry {
+ItemIdentifier
+Quantity
+MaxPrice
+Filters
}
class VendorSellAgentEntry {
+ItemIdentifier
+MinPrice
+Quantity
}
class ShopListEntry {
+ItemId
+Name
+Price
+Stock
}
class SellListEntry {
+ItemId
+Quantity
+TargetPrice
}
class XYComparer {
+Compare(x,y) int
}
VendorBuyAgentEntry --> ShopListEntry : "matches"
VendorSellAgentEntry --> SellListEntry : "queues"
ShopListEntry <.. XYComparer : "sorts"
SellListEntry <.. XYComparer : "sorts"
```
**Diagram sources**
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs)
#### Sequence Diagram: Automated Buy Flow
```mermaid
sequenceDiagram
participant UI as "VendorBuyTabControl"
participant VM as "VendorBuyTabViewModel"
participant Model as "ShopListEntry"
participant Rule as "VendorBuyAgentEntry"
participant Net as "VendorBuy Packet"
UI->>VM : StartBuy()
VM->>Model : Load shop items
VM->>Rule : Evaluate price cap and filters
alt Meets criteria
VM->>Net : Send VendorBuy(itemId, qty)
Net-->>VM : Success/Failure
VM-->>UI : Update stock and logs
else Does not meet criteria
VM-->>UI : Skip item
end
```
**Diagram sources**
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
#### Flowchart: Profitability Check for Sells
```mermaid
flowchart TD
Start(["Start Sell Evaluation"]) --> LoadPrices["Load Vendor Buyback Prices"]
LoadPrices --> Compare{"Meets Min Price?"}
Compare --> |No| Skip["Skip Item"]
Compare --> |Yes| CheckQty["Check Inventory Quantity"]
CheckQty --> HasQty{"Has Enough Stock?"}
HasQty --> |No| Insufficient["Log Insufficient Stock"]
HasQty --> |Yes| QueueSell["Queue Sell Entry"]
QueueSell --> End(["End"])
Insufficient --> End
Skip --> End
```
**Diagram sources**
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
## Dependency Analysis
- VendorBuyTabViewModel depends on VendorBuyAgentEntry and ShopListEntry to evaluate and execute buys.
- VendorSellTabViewModel depends on VendorSellAgentEntry and SellListEntry to evaluate and execute sells.
- Both view models rely on Avalonia tab controls for UI binding and interaction.
- The buy workflow uses the VendorBuy packet to communicate with the server.
```mermaid
graph LR
VBT["VendorBuyTabControl"] --> VBVM["VendorBuyTabViewModel"]
VST["VendorSellTabControl"] --> VSVM["VendorSellTabViewModel"]
VBVM --> VBAE["VendorBuyAgentEntry"]
VBVM --> SLE["ShopListEntry"]
VSVM --> VSAE["VendorSellAgentEntry"]
VSVM --> SLSE["SellListEntry"]
VBVM --> VBP["VendorBuy Packet"]
```
**Diagram sources**
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
- [VendorSellTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.axaml.cs)
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
**Section sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
- [VendorBuyTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.axaml.cs)
- [VendorSellTabControl.axaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.axaml.cs)
- [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs)
- [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs)
- [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs)
- [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs)
- [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)
## Performance Considerations
- Batch operations: Group multiple buy/sell requests where possible to reduce network overhead.
- Efficient matching: Use comparers and indexes to quickly filter shop items and inventory.
- Throttling: Avoid flooding the server with rapid requests; introduce small delays between transactions.
- UI responsiveness: Offload heavy computations to background tasks and marshal updates to the UI thread.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Insufficient funds:
- Ensure the player has enough gold before initiating buys.
- Validate budget constraints in the buy agent configuration.
- Vendor limitations:
- Respect per-item purchase limits enforced by the vendor.
- Handle cases where stock drops below requested quantity.
- Network connectivity issues:
- Retry failed transactions with backoff.
- Provide clear error messages and allow manual resumption.
- Price volatility:
- Re-evaluate prices before each transaction to avoid outdated assumptions.
- Log discrepancies between expected and actual costs.
Operational tips:
- Monitor logs for failures and partial successes.
- Use stock tracking to prevent overselling or overbuying.
- Confirm vendor interactions are active and reachable before starting automation.
**Section sources**
- [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs)
- [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs)
## Conclusion
The Vendor Management system integrates structured data models, robust view models, and Avalonia UI components to automate buying and selling with NPCs. By leveraging VendorBuyAgentEntry and VendorSellAgentEntry alongside ShopListEntry and SellListEntry, the system supports flexible trading strategies, price monitoring, and stock tracking. Proper error handling ensures resilience against insufficient funds, vendor limits, and network issues, enabling reliable bulk purchasing, profit maximization, and inventory restocking workflows.