Skip to main content

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//! ```
54
55pub mod abilities;
56pub mod demo;
57pub mod entity;
58pub mod error;
59pub mod game_modes;
60pub mod heroes;
61pub mod io;
62pub mod modifiers;
63pub mod patron_phases;
64pub mod position;
65pub mod teams;
66
67// Re-export commonly used types at the crate root for convenience
68pub use abilities::{ability_name, all_abilities};
69pub use demo::{
70    CmdHeader, Context, GameEvent, MessageInfo, Parser, command_name, decode_event_payload,
71};
72pub use entity::{
73    ClassEntry, ClassInfo, ENTITY_HANDLE_INDEX_MASK, Entity, EntityContainer, FieldValue,
74    INVALID_ENTITY_HANDLE, Serializer, SerializerContainer, SerializerField, StringTable,
75    StringTableContainer, StringTableEntry, protobuf_handle_index,
76};
77pub use error::{Error, Result};
78pub use game_modes::{all_game_modes, game_mode_name};
79pub use heroes::{all_heroes, hero_name};
80pub use modifiers::{all_modifiers, modifier_name};
81pub use patron_phases::{all_patron_phases, patron_phase_name};
82pub use position::{CELL_BITS, CELL_SIZE, WORLD_HALF, cell_to_world};
83pub use teams::{all_teams, team_name};