boon/lib.rs
1//! Boon - A Deadlock demo file parser
2//!
3//! This crate provides functionality for parsing Deadlock demo files (.dem),
4//! extracting game state, entity information, and metadata.
5//!
6//! # Quick start
7//!
8//! ```no_run
9//! use std::path::Path;
10//! use boon::Parser;
11//!
12//! let parser = Parser::from_file(Path::new("match.dem")).unwrap();
13//! let header = parser.file_header().unwrap();
14//! println!("Map: {:?}", header.map_name);
15//! ```
16//!
17//! # Reading game events
18//!
19//! ```no_run
20//! use std::path::Path;
21//! use boon::Parser;
22//!
23//! let parser = Parser::from_file(Path::new("match.dem")).unwrap();
24//! let events = parser.events(None).unwrap();
25//! for event in &events {
26//! println!("[tick {}] {} (msg_type {})", event.tick, event.name, event.msg_type);
27//! }
28//! ```
29//!
30//! # Iterating entities per tick
31//!
32//! ```no_run
33//! use std::path::Path;
34//! use boon::Parser;
35//!
36//! let parser = Parser::from_file(Path::new("match.dem")).unwrap();
37//! parser.run_to_end(|ctx| {
38//! for (&idx, entity) in ctx.entities.iter() {
39//! if entity.class_name == "CCitadelPlayerPawn" {
40//! // Access entity fields by resolved key
41//! }
42//! }
43//! }).unwrap();
44//! ```
45//!
46//! # Name lookups
47//!
48//! ```
49//! // Resolve numeric IDs to human-readable names
50//! assert_eq!(boon::hero_name(1), "Infernus");
51//! assert_eq!(boon::team_name(2), "Hidden King");
52//! assert_eq!(boon::team_name(3), "Archmother");
53//! assert_eq!(boon::hitgroup_name(1), "head");
54//! assert_eq!(boon::lifestate_name(0), "alive");
55//! ```
56
57pub mod abilities;
58pub mod demo;
59pub mod entity;
60pub mod error;
61pub mod game_modes;
62pub mod heroes;
63pub mod hitgroups;
64pub mod io;
65pub mod lifestates;
66pub mod modifiers;
67pub mod patron_phases;
68pub mod position;
69pub mod teams;
70
71// Re-export commonly used types at the crate root for convenience
72pub use abilities::{ability_name, all_abilities};
73pub use demo::{
74 CmdHeader, Context, GameEvent, MessageInfo, Parser, command_name, decode_event_payload,
75};
76pub use entity::{
77 ClassEntry, ClassInfo, ENTITY_HANDLE_INDEX_MASK, Entity, EntityContainer, FieldValue,
78 INVALID_ENTITY_HANDLE, Serializer, SerializerContainer, SerializerField, StringTable,
79 StringTableContainer, StringTableEntry, protobuf_handle_index,
80};
81pub use error::{Error, Result};
82pub use game_modes::{all_game_modes, game_mode_name};
83pub use heroes::{all_heroes, hero_name};
84pub use hitgroups::{all_hitgroups, hitgroup_name};
85pub use lifestates::{all_lifestates, lifestate_name};
86pub use modifiers::{all_modifiers, modifier_name};
87pub use patron_phases::{all_patron_phases, patron_phase_name};
88pub use position::{CELL_BITS, CELL_SIZE, WORLD_HALF, cell_to_world};
89pub use teams::{all_teams, team_name};