17 KiB
Object Inspector
**Referenced Files in This Document** - [ObjectInspectorWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/ObjectInspectorWindow.axaml.cs) - [ObjectInspectorViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/ObjectInspectorViewModel.cs) - [ObjectInspectorData.cs](file://ClassicAssist.Shared/UI/Models/ObjectInspectorData.cs) - [ObjectInspector.cs](file://ClassicAssist/Data/Hotkeys/Commands/ObjectInspector.cs) - [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs) - [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs) - [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs) - [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs) - [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)Table of Contents
- Introduction
- Project Structure
- Core Components
- Architecture Overview
- Detailed Component Analysis
- Entity Types and Inspection
- Hotkey Integration
- Memory Analysis Features
- Performance Considerations
- Troubleshooting Guide
- Conclusion
Introduction
The Object Inspector is a powerful debugging and analysis tool within ClassicAssist.Avalonia that provides real-time inspection capabilities for game objects. It enables developers and advanced users to examine the internal state, properties, and relationships of various entity types including Mobiles (characters), Items (objects), and Gumps (user interface elements). The tool offers hierarchical navigation through object trees, property filtering, memory analysis, and comprehensive attribute examination.
This documentation explains how to access and utilize the Object Inspector's features effectively during development and debugging sessions, covering everything from basic object inspection to advanced memory analysis techniques.
Project Structure
The Object Inspector implementation follows a clean MVVM (Model-View-ViewModel) architecture pattern, separating concerns between the user interface, business logic, and data models:
graph TB
subgraph "UI Layer"
OIW["ObjectInspectorWindow.axaml.cs"]
OIXAML["ObjectInspectorWindow.axaml"]
end
subgraph "ViewModel Layer"
OIVM["ObjectInspectorViewModel.cs"]
end
subgraph "Model Layer"
OID["ObjectInspectorData.cs"]
ENT["Entity.cs"]
MOB["Mobile.cs"]
ITM["Item.cs"]
GMP["Gump.cs"]
PROP["Property.cs"]
end
subgraph "Hotkey System"
OHK["ObjectInspector.cs"]
end
OIW --> OIVM
OIXAML --> OIVM
OIVM --> OID
OID --> ENT
ENT --> MOB
ENT --> ITM
ENT --> GMP
ENT --> PROP
OHK --> OIW
Diagram sources
- ObjectInspectorWindow.axaml.cs
- ObjectInspectorViewModel.cs
- ObjectInspectorData.cs
- ObjectInspector.cs
Section sources
Core Components
ObjectInspectorWindow
The main window component that hosts the Object Inspector interface. It manages window lifecycle, layout, and user interactions while delegating business logic to the ViewModel layer.
ObjectInspectorViewModel
The central business logic component that orchestrates object inspection operations, manages data binding, handles filtering and sorting, and coordinates communication between the UI and underlying game engine.
ObjectInspectorData
The data model that represents inspected objects and their properties. It provides a structured representation of game entities suitable for display and manipulation in the inspector interface.
Hotkey Command Integration
The Object Inspector integrates with the hotkey system through a dedicated command class that allows quick access via keyboard shortcuts.
Section sources
- ObjectInspectorWindow.axaml.cs
- ObjectInspectorViewModel.cs
- ObjectInspectorData.cs
- ObjectInspector.cs
Architecture Overview
The Object Inspector implements a layered architecture that separates presentation, business logic, and data access concerns:
sequenceDiagram
participant User as "User"
participant Window as "ObjectInspectorWindow"
participant VM as "ObjectInspectorViewModel"
participant Engine as "Game Engine"
participant Entities as "Entity Collections"
User->>Window : Open Object Inspector
Window->>VM : Initialize ViewModel
VM->>Engine : Request Entity Data
Engine->>Entities : Query Active Objects
Entities-->>Engine : Return Entity Lists
Engine-->>VM : Provide Entity Data
VM->>VM : Process and Filter Data
VM-->>Window : Bind Inspectable Objects
Window-->>User : Display Object Hierarchy
User->>Window : Select Object
Window->>VM : Handle Selection Change
VM->>Engine : Get Object Properties
Engine-->>VM : Return Property Collection
VM-->>Window : Update Property Grid
Window-->>User : Show Object Details
Diagram sources
Detailed Component Analysis
ObjectInspectorViewModel Architecture
The ViewModel serves as the central coordinator for all Object Inspector functionality:
classDiagram
class ObjectInspectorViewModel {
+ObservableCollection~ObjectInspectorData~ SelectedObjects
+string FilterText
+bool IsFilteringEnabled
+void RefreshObjects()
+void ApplyFilter(string filter)
+void ExpandNode(ObjectInspectorData node)
+void CollapseNode(ObjectInspectorData node)
+void ExportProperties(ObjectInspectorData obj)
-IEnumerable~PropertyInfo~ GetInspectableProperties(object obj)
-ObjectInspectorData CreateObjectWrapper(object entity)
-bool MatchesFilter(ObjectInspectorData obj, string filter)
}
class ObjectInspectorData {
+object TargetObject
+string DisplayName
+string ObjectType
+ObservableCollection~ObjectInspectorData~ Children
+ObservableCollection~PropertyInfo~ Properties
+bool IsExpanded
+bool HasChildren
+void LoadProperties()
+void LoadChildren()
}
class Entity {
<<abstract>>
+int Serial
+string Name
+int Hue
+int X
+int Y
+int Z
+Map Map
}
class Mobile {
+int Body
+int SkillCap
+int Gold
+bool IsDead
+bool IsPlayer
}
class Item {
+int Amount
+int Weight
+int Value
+bool IsStackable
+Container Parent
}
class Gump {
+int Width
+int Height
+bool IsVisible
+GumpElement[] Elements
}
ObjectInspectorViewModel --> ObjectInspectorData : creates
ObjectInspectorData --> Entity : wraps
Entity <|-- Mobile
Entity <|-- Item
Entity <|-- Gump
Diagram sources
Property Reflection System
The Object Inspector uses reflection to dynamically discover and display object properties:
flowchart TD
Start([Start Property Inspection]) --> GetObjectType["Get Object Type"]
GetObjectType --> GetProperties["Get All Public Properties"]
GetProperties --> FilterProperties{"Apply Filters?"}
FilterProperties --> |Yes| ApplyFilters["Filter Based on Criteria"]
FilterProperties --> |No| SkipFilters["Skip Filtering"]
ApplyFilters --> ProcessProperties["Process Filtered Properties"]
SkipFilters --> ProcessProperties
ProcessProperties --> CreatePropertyInfo["Create PropertyInfo Objects"]
CreatePropertyInfo --> AddToCollection["Add to Observable Collection"]
AddToCollection --> End([Return Properties])
Diagram sources
Section sources
Entity Types and Inspection
Mobile Objects
Mobile objects represent living entities in the game world, including players, NPCs, and creatures. The Object Inspector provides detailed inspection of mobile-specific attributes:
- Basic Attributes: Serial number, name, hue, position (X, Y, Z coordinates), and map location
- Combat State: Health, mana, stamina, combat status, and notoriety information
- Skills and Abilities: Skill levels, special moves, and ability cooldowns
- Equipment: Currently equipped items and inventory contents
- Status Effects: Active buffs, debuffs, and condition states
Item Objects
Item objects represent physical and virtual items in the game world:
- Physical Properties: Weight, value, durability, and stack count
- Location Information: Container hierarchy, position, and ownership
- Custom Properties: Player-defined attributes and metadata
- Visual Attributes: Hue, art ID, and visual effects
- Usage Properties: Usability flags, required skills, and consumption behavior
Gump Objects
Gump objects represent user interface elements and interactive windows:
- Layout Properties: Position, size, and z-order
- Element Hierarchy: Child elements, buttons, and text fields
- State Management: Visibility, enabled/disabled states, and event handlers
- Content Properties: Text content, images, and dynamic data binding
Section sources
Hotkey Integration
The Object Inspector integrates seamlessly with ClassicAssist's hotkey system, allowing quick access through customizable keyboard shortcuts:
Access Methods
- Default Hotkey: Press the configured hotkey combination to toggle the Object Inspector window
- Command Line: Use macro commands to programmatically open or control the inspector
- Menu Integration: Access through the main application menu if configured
Hotkey Configuration
Users can customize the Object Inspector hotkey through the hotkey management interface:
- Navigate to Settings → Hotkeys
- Search for "Object Inspector" in the command list
- Assign desired key combination
- Save configuration changes
Programmatic Control
The Object Inspector exposes command methods for automation and scripting:
sequenceDiagram
participant Macro as "Macro Script"
participant Commands as "Command Manager"
participant Inspector as "Object Inspector"
Macro->>Commands : Execute "OpenObjectInspector"
Commands->>Inspector : Toggle Window State
Inspector->>Inspector : Refresh Current View
Inspector-->>Macro : Operation Complete
Diagram sources
Section sources
Memory Analysis Features
Object Hierarchy Navigation
The Object Inspector provides hierarchical navigation through complex object relationships:
- Tree View: Visual tree representation of parent-child relationships
- Breadcrumb Navigation: Quick navigation path to current selection
- Search Functionality: Find specific objects by name, serial, or type
- Filter Options: Filter by object type, visibility, or custom criteria
Property Analysis Tools
Advanced property analysis capabilities include:
- Type Detection: Automatic detection of property types and appropriate display formats
- Value Comparison: Compare property values across different objects or time periods
- Change Tracking: Monitor property changes in real-time during gameplay
- Export Capabilities: Export property data for external analysis or reporting
Memory Usage Monitoring
The Object Inspector includes memory analysis features to help identify performance issues:
- Object Count Statistics: Track number of active objects by type
- Memory Footprint Estimation: Estimate memory usage of inspected objects
- Leak Detection: Identify potential memory leaks through object lifetime monitoring
- Garbage Collection Impact: Monitor GC pressure during intensive inspection operations
Section sources
Performance Considerations
Large Dataset Optimization
When inspecting large numbers of entities, consider the following optimization strategies:
- Lazy Loading: Properties are loaded on-demand rather than all at once
- Virtual Scrolling: Efficient rendering of large lists using virtualization
- Background Processing: Heavy operations run on background threads to maintain UI responsiveness
- Caching: Frequently accessed data is cached to reduce repeated calculations
Memory Management Best Practices
- Dispose Pattern: Proper disposal of large object collections when no longer needed
- Weak References: Use weak references for long-lived object caches to prevent memory leaks
- Batch Operations: Process large datasets in batches to avoid memory spikes
- GC Pressure Monitoring: Monitor garbage collection frequency during intensive operations
UI Responsiveness
- Progressive Rendering: Update UI incrementally rather than blocking the main thread
- Throttled Updates: Limit update frequency for rapidly changing properties
- Asynchronous Operations: Perform network or disk I/O operations asynchronously
- Cancellation Support: Allow cancellation of long-running inspection operations
Troubleshooting Guide
Common Issues and Solutions
Object Inspector Not Opening
- Check Hotkey Configuration: Verify the assigned hotkey doesn't conflict with other commands
- Window State: Check if the window is minimized or hidden behind other applications
- Permission Issues: Ensure the application has necessary permissions to access game memory
Slow Performance with Many Objects
- Enable Filtering: Use filters to limit the number of displayed objects
- Disable Auto-Refresh: Turn off automatic refresh for static inspections
- Reduce Property Depth: Limit nested property inspection depth
- Close Other Windows: Free up system resources by closing unnecessary applications
Missing Properties or Incorrect Values
- Refresh Manually: Force a manual refresh of the object data
- Check Game State: Ensure the game is in a stable state with consistent object data
- Verify Permissions: Confirm the application has proper read access to game memory
- Update Version: Ensure you're using the latest version compatible with your game client
Debugging Techniques
- Enable Verbose Logging: Increase logging verbosity to capture detailed inspection operations
- Export Data: Export object data for offline analysis when live inspection is problematic
- Isolate Issues: Test with minimal object sets to isolate performance problems
- Monitor Resources: Use system monitoring tools to track memory and CPU usage during inspection
Section sources
Conclusion
The Object Inspector in ClassicAssist.Avalonia provides a comprehensive solution for real-time game object inspection and debugging. Its modular architecture, extensive feature set, and integration with the broader ClassicAssist ecosystem make it an invaluable tool for developers and advanced users alike.
Key benefits include:
- Real-time Inspection: Live viewing of game object states without interrupting gameplay
- Comprehensive Coverage: Support for all major entity types (Mobiles, Items, Gumps)
- Flexible Interface: Hierarchical navigation, filtering, and search capabilities
- Performance Optimized: Designed to handle large numbers of objects efficiently
- Developer Friendly: Extensive debugging and analysis features for troubleshooting
For optimal results, users should leverage the filtering capabilities to focus on relevant objects, use the hotkey integration for quick access, and follow the performance guidelines when working with large datasets. The Object Inspector serves as both a development aid and a powerful diagnostic tool throughout the game development and testing lifecycle.