Skip to main content

Game

Struct Game 

Source
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: f64

Seconds 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: bool

Damage 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: bool

The level-start channel has been broadcast.

Implementations§

Source§

impl Game

Source

pub(super) fn initial_ai(&self, i: usize) -> Ai

Initial AI state for a dude placed in the map.

Source

fn holds_position(&self, i: usize) -> bool

True when the dude was placed as an ambusher or guard and has not been provoked.

Source

pub(super) fn tick_dudes(&mut self, res: &Resources, dt: f64)

Source

fn chase_step( &mut self, res: &Resources, i: usize, info: &DudeInfo, dist: f64, dt: f64, )

Source

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.

Source

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).

Source

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.

Source

fn flee_step(&mut self, i: usize, info: &DudeInfo, dt: f64)

Running away from the player (innocents, burning dudes).

Source

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.

Source

fn rise(&mut self, res: &Resources, i: usize)

Source

pub(super) fn wake(&mut self, res: &Resources, i: usize, info: &DudeInfo)

Source

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

pub(super) fn provoke(&mut self, res: &Resources, i: usize, info: &DudeInfo)

Called when a dude is hurt: provokes ambushers, wakes statues and sleepers.

Source§

impl Game

Source

pub fn save_bytes(&self, title: &str) -> Result<Vec<u8>>

Serializes the game; title describes the save (map, time…).

Source

pub fn from_save(res: &Resources, bytes: &[u8]) -> Result<Game>

Restores a game saved with Game::save_bytes.

Source

pub fn save_to(&self, path: &Path, title: &str) -> Result<()>

Source

pub fn load_from(res: &Resources, path: &Path) -> Result<Game>

Source§

impl Game

Source

pub fn load_level(res: &Resources, name: &str) -> Result<Game>

Source

pub fn load_level_skill(res: &Resources, name: &str, skill: i32) -> Result<Game>

Source

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).

Source

fn rand(&mut self) -> u32

Source

fn randf(&mut self) -> f64

Uniform float in [-1, 1].

Source

fn sound(&mut self, id: i32, at: Option<(f64, f64, f64)>)

Source

fn sound_group(&mut self, base: i32, at: (f64, f64, f64))

Source

pub fn update(&mut self, res: &Resources, input: &Input, dt: f64)

Advances the simulation by real time dt (seconds) using fixed 120 Hz ticks.

Source

fn snapshot(&mut self)

Source

fn alpha(&self) -> f64

Fraction of a tick elapsed since the last simulated tick.

Source

fn draw_pos(&self, i: usize) -> (f64, f64, f64)

Position of sprite i blended between the last two ticks.

Source

fn obstacles(&self) -> Vec<CircleObstacle>

Source

fn tick(&mut self, res: &Resources, input: &Input, dt: f64)

Source

fn carry_player(&mut self)

Moves the player along with sliding / rotating sectors they stand in.

Source

fn light_wave(&mut self, kind: u8, t: f64) -> f64

Light waveform in -1..=1 (or 0..=1) for Blood’s lighting wave types.

Source

fn sector_lighting(&mut self)

Source

fn room_transition(&mut self)

Moves the player between linked rooms when their eye crosses a portal plane.

Source

fn sector_damage(&mut self, _dt: f64)

Source

fn handle_notices(&mut self, res: &Resources)

Source

fn wall_center(&self, w: usize) -> (f64, f64, f64)

Source

fn sprite_pos(&self, i: usize) -> (f64, f64, f64)

Source

pub fn push_message(&mut self, m: String)

Source

fn teleport_from(&mut self, sector: usize)

Source

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.

Source

fn key_name(k: u8) -> &'static str

Source

fn check_key(&mut self, key: u8) -> bool

Returns false (and tells the player) when a key is required but missing.

Source

fn do_use(&mut self, res: &Resources)

Source

pub fn start_seq(&mut self, res: &Resources, i: usize, id: u32)

Source

fn play_dude_anim(&mut self, res: &Resources, i: usize, suffix: &str) -> bool

Source

fn apply_seq_frame(&mut self, res: &Resources, i: usize, frame: i32) -> bool

Source

fn tick_seqs(&mut self, res: &Resources)

Advances all sprite sequences; fires callbacks on trigger frames.

Source

fn seq_finished(&mut self, res: &Resources, i: usize)

Source

fn seq_callback(&mut self, res: &Resources, i: usize)

Source

fn can_see_player(&self, i: usize) -> bool

Source

fn dude_mover(info: &DudeInfo) -> Mover

Source

fn dude_gravity(&mut self, i: usize, info: &DudeInfo, dt: f64)

Source

fn dude_attack(&mut self, res: &Resources, i: usize)

Source

fn player_cylinder(&self) -> HitCylinder

Source

fn tick_inventory(&mut self, input: &Input, dt: f64)

Inventory keys, power-up timers and breathing.

Source

pub fn damage_player(&mut self, amount: i32, _from: Option<usize>)

Source

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.

Source

pub fn damage_sprite( &mut self, res: &Resources, i: usize, amount: i32, explosive: bool, )

Applies damage to a sprite (dudes and destructible things).

Source

fn kill_dude(&mut self, res: &Resources, i: usize, info: &DudeInfo, gib: bool)

Source

fn spawn_item(&mut self, t: i16, x: f64, y: f64, sect: i32)

Source

fn ensure_slots(&mut self, i: usize)

Source

pub fn spawn_fx( &mut self, seq: u32, x: f64, y: f64, z: f64, sect: i32, ) -> Option<usize>

Source

fn explode( &mut self, res: &Resources, x: f64, y: f64, z: f64, sect: i32, radius: f64, damage: i32, fire: bool, )

Source

fn spawn_projectile( &mut self, kind: ProjKind, x: f64, y: f64, z: f64, sect: i32, ang: f64, dz: f64, owner: i64, ) -> Option<usize>

Source

fn proj_kind(t: i16) -> Option<ProjKind>

Source

fn tick_projectiles(&mut self, res: &Resources, dt: f64)

Source

fn tick_weapon(&mut self, res: &Resources, fire: bool, alt: bool)

Source

fn player_aim(&self) -> (f64, f64, f64)

Aim vector (dx, dy, dz) for the player, with light vertical auto-aim.

Source

fn player_shoot(&mut self, res: &Resources)

Source

fn fire_once( &mut self, res: &Resources, kind: Fire, dx: f64, dy: f64, dz: f64, side: f64, )

Source

fn dude_cylinders(&self, x: f64, y: f64) -> Vec<HitCylinder>

Source

fn check_pickups_and_proximity(&mut self)

Source

fn apply_pickup(&mut self, p: Pickup) -> bool

Source

pub fn camera(&self) -> Camera

Source

pub fn ai_state(&self, i: usize) -> Option<Ai>

AI state of sprite i (for tests and debugging).

Source

pub fn item_pic(&self, t: i16) -> Option<i32>

Tile used by an item type in this level (for HUD icons).

Source

pub fn weapon_view(&self) -> (u32, i32)

Current weapon QAV and its elapsed ticks, for the HUD.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.