pub struct Game {Show 32 fields
pub world: World,
pub player: Player,
pub triggers: Triggers,
pub arsenal: Arsenal,
pub anims: AnimLib,
pub clock: i32,
pub events: Vec<GameEvent>,
pub messages: Vec<String>,
pub kills: i32,
pub total_kills: i32,
pub damage_flash: f64,
pub pickup_flash: f64,
pub skill: i32,
last_sector: i32,
acc: f64,
use_down: bool,
rng: u32,
ai: Vec<Ai>,
attack_cd: Vec<f64>,
pic_for_type: HashMap<i16, i16>,
weapon_switch_down: bool,
level_messages: HashMap<u32, String>,
pub inventory: Inventory,
pub powerups: Powerups,
pub air: f64,
inv_keys: (bool, bool, bool),
provoked: Vec<bool>,
sees: Vec<bool>,
burn_kill: bool,
prev_xyz: Vec<(i32, i32, i32)>,
prev_eye: (f64, f64, f64),
pub started: bool,
}Fields§
§world: World§player: Player§triggers: Triggers§arsenal: Arsenal§anims: AnimLib§clock: i32§events: Vec<GameEvent>§messages: Vec<String>§kills: i32§total_kills: i32§damage_flash: f64§pickup_flash: f64§skill: i32§last_sector: i32§acc: f64§use_down: bool§rng: u32§ai: Vec<Ai>§attack_cd: Vec<f64>§pic_for_type: HashMap<i16, i16>§weapon_switch_down: bool§level_messages: HashMap<u32, String>§inventory: Inventory§powerups: Powerups§air: f64Seconds of breath left underwater.
inv_keys: (bool, bool, bool)§provoked: Vec<bool>Dude was hurt (ambushers/guards start moving).
sees: Vec<bool>Cached line-of-sight to the player.
burn_kill: boolDamage currently being applied comes from burning.
prev_xyz: Vec<(i32, i32, i32)>Sprite positions and player eye before the last tick, for drawing frames between ticks (smooth motion at any frame rate).
prev_eye: (f64, f64, f64)§started: boolThe level-start channel has been broadcast.
Implementations§
Source§impl Game
impl Game
Sourcepub(super) fn initial_ai(&self, i: usize) -> Ai
pub(super) fn initial_ai(&self, i: usize) -> Ai
Initial AI state for a dude placed in the map.
Sourcefn holds_position(&self, i: usize) -> bool
fn holds_position(&self, i: usize) -> bool
True when the dude was placed as an ambusher or guard and has not been provoked.
pub(super) fn tick_dudes(&mut self, res: &Resources, dt: f64)
fn chase_step( &mut self, res: &Resources, i: usize, info: &DudeInfo, dist: f64, dt: f64, )
Sourcefn dude_walk(&mut self, i: usize, info: &DudeInfo, ang: f64, dist: f64) -> bool
fn dude_walk(&mut self, i: usize, info: &DudeInfo, ang: f64, dist: f64) -> bool
Moves a dude dist units toward ang, sliding around obstacles and refusing to
step off high ledges. Returns true if it moved.
Moves that keep (almost) full speed win over grinding along an obstacle: the first pass accepts only those, trying straight ahead, then wider detours in a fixed order; the second pass falls back to any move that gets somewhere. That way a dude rounds an obstacle briskly, like the E4M9 axe zombies around the central planter in the original.
Sourcefn crowded(
&self,
i: usize,
info: &DudeInfo,
x: f64,
y: f64,
nx: f64,
ny: f64,
) -> bool
fn crowded( &self, i: usize, info: &DudeInfo, x: f64, y: f64, nx: f64, ny: f64, ) -> bool
True when moving dude i from (x, y) to (nx, ny) pushes it further into another
live dude or the player (dudes don’t walk through each other).
Sourcefn idle_wander(
&mut self,
res: &Resources,
i: usize,
info: &DudeInfo,
dist: f64,
dt: f64,
)
fn idle_wander( &mut self, res: &Resources, i: usize, info: &DudeInfo, dist: f64, dt: f64, )
Unalerted dudes don’t stand frozen: they take a few slow steps around their spawn point, pause, and wander again. Ambushers, statues and sleepers stay put.
Sourcefn flee_step(&mut self, i: usize, info: &DudeInfo, dt: f64)
fn flee_step(&mut self, i: usize, info: &DudeInfo, dt: f64)
Running away from the player (innocents, burning dudes).
Sourcefn tick_burning(
&mut self,
res: &Resources,
i: usize,
info: &DudeInfo,
dt: f64,
) -> bool
fn tick_burning( &mut self, res: &Resources, i: usize, info: &DudeInfo, dt: f64, ) -> bool
Burning dudes panic and take damage. Returns true when burning handled the tick.
fn rise(&mut self, res: &Resources, i: usize)
pub(super) fn wake(&mut self, res: &Resources, i: usize, info: &DudeInfo)
Sourcepub(super) fn alert_nearby(&mut self, res: &Resources, radius: f64)
pub(super) fn alert_nearby(&mut self, res: &Resources, radius: f64)
Wakes dudes that can hear the player’s weapon (deaf dudes ignore noise).
Source§impl Game
impl Game
Sourcepub fn save_bytes(&self, title: &str) -> Result<Vec<u8>>
pub fn save_bytes(&self, title: &str) -> Result<Vec<u8>>
Serializes the game; title describes the save (map, time…).
Sourcepub fn from_save(res: &Resources, bytes: &[u8]) -> Result<Game>
pub fn from_save(res: &Resources, bytes: &[u8]) -> Result<Game>
Restores a game saved with Game::save_bytes.
pub fn save_to(&self, path: &Path, title: &str) -> Result<()>
pub fn load_from(res: &Resources, path: &Path) -> Result<Game>
Source§impl Game
impl Game
pub fn load_level(res: &Resources, name: &str) -> Result<Game>
pub fn load_level_skill(res: &Resources, name: &str, skill: i32) -> Result<Game>
Sourcefn fix_sprite_sectors(&mut self)
fn fix_sprite_sectors(&mut self)
Some maps store pickups, dudes and blocking sprites with the sector number of a neighbour, or (in stacked rooms) of a sector at another height. Such a sprite would collide, light and draw with the wrong floor, or never be drawn. Reassign it to the sector that contains its position and height (or at least its position).
fn rand(&mut self) -> u32
fn sound(&mut self, id: i32, at: Option<(f64, f64, f64)>)
fn sound_group(&mut self, base: i32, at: (f64, f64, f64))
Sourcepub fn update(&mut self, res: &Resources, input: &Input, dt: f64)
pub fn update(&mut self, res: &Resources, input: &Input, dt: f64)
Advances the simulation by real time dt (seconds) using fixed 120 Hz ticks.
fn snapshot(&mut self)
Sourcefn draw_pos(&self, i: usize) -> (f64, f64, f64)
fn draw_pos(&self, i: usize) -> (f64, f64, f64)
Position of sprite i blended between the last two ticks.
fn obstacles(&self) -> Vec<CircleObstacle>
fn tick(&mut self, res: &Resources, input: &Input, dt: f64)
Sourcefn carry_player(&mut self)
fn carry_player(&mut self)
Moves the player along with sliding / rotating sectors they stand in.
Sourcefn light_wave(&mut self, kind: u8, t: f64) -> f64
fn light_wave(&mut self, kind: u8, t: f64) -> f64
Light waveform in -1..=1 (or 0..=1) for Blood’s lighting wave types.
fn sector_lighting(&mut self)
Sourcefn room_transition(&mut self)
fn room_transition(&mut self)
Moves the player between linked rooms when their eye crosses a portal plane.
fn sector_damage(&mut self, _dt: f64)
fn handle_notices(&mut self, res: &Resources)
fn wall_center(&self, w: usize) -> (f64, f64, f64)
fn sprite_pos(&self, i: usize) -> (f64, f64, f64)
pub fn push_message(&mut self, m: String)
fn teleport_from(&mut self, sector: usize)
Sourcepub fn trace_wall(
&self,
x: f64,
y: f64,
z: f64,
sect: i32,
ang: f64,
max: f64,
) -> Option<(usize, f64)>
pub fn trace_wall( &self, x: f64, y: f64, z: f64, sect: i32, ang: f64, max: f64, ) -> Option<(usize, f64)>
Traces a horizontal ray through open portals. Returns the first blocking wall and distance.
fn key_name(k: u8) -> &'static str
Sourcefn check_key(&mut self, key: u8) -> bool
fn check_key(&mut self, key: u8) -> bool
Returns false (and tells the player) when a key is required but missing.
fn do_use(&mut self, res: &Resources)
pub fn start_seq(&mut self, res: &Resources, i: usize, id: u32)
fn play_dude_anim(&mut self, res: &Resources, i: usize, suffix: &str) -> bool
fn apply_seq_frame(&mut self, res: &Resources, i: usize, frame: i32) -> bool
Sourcefn tick_seqs(&mut self, res: &Resources)
fn tick_seqs(&mut self, res: &Resources)
Advances all sprite sequences; fires callbacks on trigger frames.
fn seq_finished(&mut self, res: &Resources, i: usize)
fn seq_callback(&mut self, res: &Resources, i: usize)
fn can_see_player(&self, i: usize) -> bool
fn dude_mover(info: &DudeInfo) -> Mover
fn dude_gravity(&mut self, i: usize, info: &DudeInfo, dt: f64)
fn dude_attack(&mut self, res: &Resources, i: usize)
fn player_cylinder(&self) -> HitCylinder
Sourcefn tick_inventory(&mut self, input: &Input, dt: f64)
fn tick_inventory(&mut self, input: &Input, dt: f64)
Inventory keys, power-up timers and breathing.
pub fn damage_player(&mut self, amount: i32, _from: Option<usize>)
Sourcepub fn damage_sprite_kind(
&mut self,
res: &Resources,
i: usize,
amount: i32,
explosive: bool,
fire: bool,
)
pub fn damage_sprite_kind( &mut self, res: &Resources, i: usize, amount: i32, explosive: bool, fire: bool, )
Damage that may set the target on fire.
Sourcepub fn damage_sprite(
&mut self,
res: &Resources,
i: usize,
amount: i32,
explosive: bool,
)
pub fn damage_sprite( &mut self, res: &Resources, i: usize, amount: i32, explosive: bool, )
Applies damage to a sprite (dudes and destructible things).
fn kill_dude(&mut self, res: &Resources, i: usize, info: &DudeInfo, gib: bool)
fn spawn_item(&mut self, t: i16, x: f64, y: f64, sect: i32)
fn ensure_slots(&mut self, i: usize)
pub fn spawn_fx( &mut self, seq: u32, x: f64, y: f64, z: f64, sect: i32, ) -> Option<usize>
fn explode( &mut self, res: &Resources, x: f64, y: f64, z: f64, sect: i32, radius: f64, damage: i32, fire: bool, )
fn spawn_projectile( &mut self, kind: ProjKind, x: f64, y: f64, z: f64, sect: i32, ang: f64, dz: f64, owner: i64, ) -> Option<usize>
fn proj_kind(t: i16) -> Option<ProjKind>
fn tick_projectiles(&mut self, res: &Resources, dt: f64)
fn tick_weapon(&mut self, res: &Resources, fire: bool, alt: bool)
Sourcefn player_aim(&self) -> (f64, f64, f64)
fn player_aim(&self) -> (f64, f64, f64)
Aim vector (dx, dy, dz) for the player, with light vertical auto-aim.
fn player_shoot(&mut self, res: &Resources)
fn fire_once( &mut self, res: &Resources, kind: Fire, dx: f64, dy: f64, dz: f64, side: f64, )
fn dude_cylinders(&self, x: f64, y: f64) -> Vec<HitCylinder>
fn check_pickups_and_proximity(&mut self)
fn apply_pickup(&mut self, p: Pickup) -> bool
pub fn camera(&self) -> Camera
Sourcepub fn item_pic(&self, t: i16) -> Option<i32>
pub fn item_pic(&self, t: i16) -> Option<i32>
Tile used by an item type in this level (for HUD icons).
Sourcepub fn weapon_view(&self) -> (u32, i32)
pub fn weapon_view(&self) -> (u32, i32)
Current weapon QAV and its elapsed ticks, for the HUD.
Sourcepub fn sprite_draws(&self, res: &Resources, cam: &Camera) -> Vec<SpriteDraw>
pub fn sprite_draws(&self, res: &Resources, cam: &Camera) -> Vec<SpriteDraw>
Builds the renderer sprite list, resolving rotation frames for the camera.
Auto Trait Implementations§
impl Freeze for Game
impl RefUnwindSafe for Game
impl Send for Game
impl Sync for Game
impl Unpin for Game
impl UnsafeUnpin for Game
impl UnwindSafe for Game
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more