1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
use crateSerializer;
use crateClassError;
use crateHashMap;
use Rc;
/// Container for all entity classes in a replay.
///
/// Classes define the types of entities that exist in the game. Each entity
/// belongs to a class which specifies:
/// - What properties it has
/// - How those properties are encoded
/// - The class name (e.g., "CDOTA_Unit_Hero_Axe")
///
/// # Examples
///
/// ## Iterating all classes
///
/// ```no_run
/// use source2_demo::prelude::*;
///
/// # fn example(ctx: &Context) {
/// for class in ctx.classes().iter() {
/// println!("Class ID {}: {}", class.id(), class.name());
/// }
/// # }
/// ```
///
/// ## Finding a specific class
///
/// ```no_run
/// use source2_demo::prelude::*;
///
/// # fn example(ctx: &Context) -> anyhow::Result<()> {
/// // Get by class name
/// let hero_class = ctx.classes().get_by_name("CDOTA_Unit_Hero_Axe")?;
/// println!("Found class: {}", hero_class.name());
///
/// // Get by ID
/// let class = ctx.classes().get_by_id(42)?;
/// # Ok(())
/// # }
/// ```
/// Entity class definition.
///
/// Represents the type and structure of an entity. Classes define:
/// - Class ID: Numeric identifier
/// - Class name: Human-readable type name (e.g., "CDOTA_Unit_Hero_Axe")
/// - Serializer: Defines which properties exist and how they're encoded
///
/// # Class Name Patterns
///
/// Entity class names follow patterns that help identify their type:
/// - `CDOTA_Unit_Hero_*` - Dota 2 heroes
/// - `CDOTA_Unit_*` - Dota 2 NPCs and units
/// - `CDOTA_Item_*` - Dota 2 item holders
/// - `CDOTA_*` - Other Dota 2 entities
/// - `CCitadelPlayerPawn` - Deadlock players
/// - `CPlayer_*` - CS2 players
///
/// # Examples
///
/// ## Using class information
///
/// ```no_run
/// use source2_demo::prelude::*;
///
/// # fn example(entity: &Entity) {
/// let class = entity.class();
/// println!("Entity ID: {}", class.id());
/// println!("Entity name: {}", class.name());
///
/// // Check entity type
/// if class.name().starts_with("CDOTA_Unit_Hero_") {
/// println!("This is a hero!");
/// }
/// # }
/// ```
///
/// ## Finding all entities of a class type
///
/// ```no_run
/// use source2_demo::prelude::*;
///
/// # fn example(ctx: &Context) -> anyhow::Result<()> {
/// // Find all heroes
/// let heroes: Vec<&Entity> = ctx.entities()
/// .iter()
/// .filter(|e| e.class().name().starts_with("CDOTA_Unit_Hero_"))
/// .collect();
/// # Ok(())
/// # }
/// ```