Merge pull request #2778 from ludovic111/refactor/cut-health-rules
🤖 Agent: move only: HealthRules (and its Default) go from health.rs to world.rs (re-exported from health), cutting world -> health (step B of the cycle plan). pr_ready --quick green (1323 tests). Queued once pr_ready was green, as the orchestrator asked; merge after verify and parity pass.
This commit is contained in:
@@ -25,29 +25,7 @@ use std::{fs, io, path::Path};
|
||||
pub(crate) type Attributes = LiveAttributes<Box<dyn FnMut() -> i32>>;
|
||||
pub(crate) type State = HurtState<DamageTypeId>;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct HealthRules {
|
||||
pub difficulty: Difficulty,
|
||||
pub natural_regeneration: bool,
|
||||
/// The `drowning_damage`, `fall_damage`, `fire_damage` and
|
||||
/// `freeze_damage` rules `Player.isInvulnerableTo` reads.
|
||||
pub drowning_damage: bool,
|
||||
pub fall_damage: bool,
|
||||
pub fire_damage: bool,
|
||||
pub freeze_damage: bool,
|
||||
}
|
||||
impl Default for HealthRules {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
difficulty: Difficulty::Normal,
|
||||
natural_regeneration: true,
|
||||
drowning_damage: true,
|
||||
fall_damage: true,
|
||||
fire_damage: true,
|
||||
freeze_damage: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub use crate::world::HealthRules;
|
||||
pub struct HealthResources {
|
||||
pub damage: Catalog,
|
||||
pub ids: PlayerFloatIds,
|
||||
|
||||
@@ -53,7 +53,7 @@ pub struct World {
|
||||
pub chunks: crate::chunk_map::ChunkMap,
|
||||
pub random: LegacyRandom,
|
||||
pub revision: u64,
|
||||
pub health_rules: crate::health::HealthRules,
|
||||
pub health_rules: HealthRules,
|
||||
pub air: BlockStateId,
|
||||
/// Sections whose geometry changed and need remeshing.
|
||||
pub dirty_sections: DirtySections,
|
||||
@@ -170,7 +170,7 @@ impl World {
|
||||
chunks: Default::default(),
|
||||
random: LegacyRandom::new(seed),
|
||||
revision: 0,
|
||||
health_rules: crate::health::HealthRules::default(),
|
||||
health_rules: HealthRules::default(),
|
||||
air,
|
||||
fast_lava: false,
|
||||
dirty_sections: Default::default(),
|
||||
@@ -377,6 +377,32 @@ impl World {
|
||||
}
|
||||
}
|
||||
|
||||
/// The game rules and difficulty a player's health reads (`Player.isInvulnerableTo`,
|
||||
/// natural regeneration), kept with the world they belong to.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct HealthRules {
|
||||
pub difficulty: horizon_world::food::Difficulty,
|
||||
pub natural_regeneration: bool,
|
||||
/// The `drowning_damage`, `fall_damage`, `fire_damage` and
|
||||
/// `freeze_damage` rules `Player.isInvulnerableTo` reads.
|
||||
pub drowning_damage: bool,
|
||||
pub fall_damage: bool,
|
||||
pub fire_damage: bool,
|
||||
pub freeze_damage: bool,
|
||||
}
|
||||
impl Default for HealthRules {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
difficulty: horizon_world::food::Difficulty::Normal,
|
||||
natural_regeneration: true,
|
||||
drowning_damage: true,
|
||||
fall_damage: true,
|
||||
fire_damage: true,
|
||||
freeze_damage: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::World;
|
||||
|
||||
Reference in New Issue
Block a user