mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
update toolchain to nightly-2021-12-19
This commit is contained in:
parent
119c802695
commit
bf48bd5346
@ -13,7 +13,7 @@ variables:
|
|||||||
# https://docs.gitlab.com/ee/ci/yaml/#shallow-cloning
|
# https://docs.gitlab.com/ee/ci/yaml/#shallow-cloning
|
||||||
GIT_DEPTH: 3
|
GIT_DEPTH: 3
|
||||||
GIT_CLEAN_FLAGS: -f
|
GIT_CLEAN_FLAGS: -f
|
||||||
CACHE_IMAGE_TAG: a4f7c998
|
CACHE_IMAGE_TAG: dd8d78be
|
||||||
|
|
||||||
default:
|
default:
|
||||||
# https://docs.gitlab.com/ee/ci/pipelines/settings.html#auto-cancel-pending-pipelines
|
# https://docs.gitlab.com/ee/ci/pipelines/settings.html#auto-cancel-pending-pipelines
|
||||||
|
@ -170,13 +170,12 @@ pub fn gen_stats(
|
|||||||
let mut result = HashMap::new();
|
let mut result = HashMap::new();
|
||||||
let mut all = timelines
|
let mut all = timelines
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(s, t)| {
|
.flat_map(|(s, t)| {
|
||||||
let mut stat = CpuTimeStats::default();
|
let mut stat = CpuTimeStats::default();
|
||||||
stat.measures.push((0, 0.0));
|
stat.measures.push((0, 0.0));
|
||||||
result.insert(s.clone(), stat);
|
result.insert(s.clone(), stat);
|
||||||
t.measures.iter().map(|e| &e.0)
|
t.measures.iter().map(|e| &e.0)
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
all.sort();
|
all.sort();
|
||||||
|
@ -88,9 +88,8 @@ impl InterpolatableComponent for Pos {
|
|||||||
}
|
}
|
||||||
let (t0prime, m0) = vel.buf[(i + vel.buf.len() - 1) % vel.buf.len()];
|
let (t0prime, m0) = vel.buf[(i + vel.buf.len() - 1) % vel.buf.len()];
|
||||||
let (t1prime, m1) = vel.buf[i % vel.buf.len()];
|
let (t1prime, m1) = vel.buf[i % vel.buf.len()];
|
||||||
let mut out;
|
|
||||||
let t = (t2 - t0) / (t1 - t0);
|
let t = (t2 - t0) / (t1 - t0);
|
||||||
if ENABLE_POSITION_HERMITE
|
let mut out = if ENABLE_POSITION_HERMITE
|
||||||
&& ((t0 - t0prime).abs() < f64::EPSILON && (t1 - t1prime).abs() < f64::EPSILON)
|
&& ((t0 - t0prime).abs() < f64::EPSILON && (t1 - t1prime).abs() < f64::EPSILON)
|
||||||
{
|
{
|
||||||
let h00 = |t: f64| (2.0 * t.powf(3.0) - 3.0 * t.powf(2.0) + 1.0) as f32;
|
let h00 = |t: f64| (2.0 * t.powf(3.0) - 3.0 * t.powf(2.0) + 1.0) as f32;
|
||||||
@ -98,7 +97,7 @@ impl InterpolatableComponent for Pos {
|
|||||||
let h01 = |t: f64| (-2.0 * t.powf(3.0) + 3.0 * t.powf(2.0)) as f32;
|
let h01 = |t: f64| (-2.0 * t.powf(3.0) + 3.0 * t.powf(2.0)) as f32;
|
||||||
let h11 = |t: f64| (t.powf(3.0) - t.powf(2.0)) as f32;
|
let h11 = |t: f64| (t.powf(3.0) - t.powf(2.0)) as f32;
|
||||||
let dt = (t1 - t0) as f32;
|
let dt = (t1 - t0) as f32;
|
||||||
out = h00(t) * p0.0 + h10(t) * dt * m0.0 + h01(t) * p1.0 + h11(t) * dt * m1.0;
|
h00(t) * p0.0 + h10(t) * dt * m0.0 + h01(t) * p1.0 + h11(t) * dt * m1.0
|
||||||
} else {
|
} else {
|
||||||
if ENABLE_POSITION_HERMITE {
|
if ENABLE_POSITION_HERMITE {
|
||||||
warn!(
|
warn!(
|
||||||
@ -106,8 +105,8 @@ impl InterpolatableComponent for Pos {
|
|||||||
interp_data, vel
|
interp_data, vel
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
out = Lerp::lerp_unclamped(p0.0, p1.0, t as f32);
|
Lerp::lerp_unclamped(p0.0, p1.0, t as f32)
|
||||||
}
|
};
|
||||||
|
|
||||||
if out.map(|x| x.is_nan()).reduce_or() {
|
if out.map(|x| x.is_nan()).reduce_or() {
|
||||||
warn!("interpolation output is nan: {}, {}, {:?}", t2, t, buf);
|
warn!("interpolation output is nan: {}, {}, {:?}", t2, t, buf);
|
||||||
|
@ -52,6 +52,7 @@ pub trait InterpolatableComponent: Component {
|
|||||||
|
|
||||||
fn new_data(x: Self) -> Self::InterpData;
|
fn new_data(x: Self) -> Self::InterpData;
|
||||||
fn update_component(&self, data: &mut Self::InterpData, time: f64, force_update: bool);
|
fn update_component(&self, data: &mut Self::InterpData, time: f64, force_update: bool);
|
||||||
|
#[must_use]
|
||||||
fn interpolate(self, data: &Self::InterpData, time: f64, read_data: &Self::ReadData) -> Self;
|
fn interpolate(self, data: &Self::InterpData, time: f64, read_data: &Self::ReadData) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +168,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
|
|||||||
.push((uid.into(), CompUpdateKind::Removed(PhantomData::<C>.into())));
|
.push((uid.into(), CompUpdateKind::Removed(PhantomData::<C>.into())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_component<'a, C: Component + Clone + Send + Sync>(
|
pub fn with_component<'a, C: Component + Clone + Send + Sync>(
|
||||||
mut self,
|
mut self,
|
||||||
uids: &ReadStorage<'a, Uid>,
|
uids: &ReadStorage<'a, Uid>,
|
||||||
|
@ -102,22 +102,26 @@ impl Default for Attack {
|
|||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
impl Attack {
|
impl Attack {
|
||||||
|
#[must_use]
|
||||||
pub fn with_damage(mut self, damage: AttackDamage) -> Self {
|
pub fn with_damage(mut self, damage: AttackDamage) -> Self {
|
||||||
self.damages.push(damage);
|
self.damages.push(damage);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_effect(mut self, effect: AttackEffect) -> Self {
|
pub fn with_effect(mut self, effect: AttackEffect) -> Self {
|
||||||
self.effects.push(effect);
|
self.effects.push(effect);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_crit(mut self, crit_chance: f32, crit_multiplier: f32) -> Self {
|
pub fn with_crit(mut self, crit_chance: f32, crit_multiplier: f32) -> Self {
|
||||||
self.crit_chance = crit_chance;
|
self.crit_chance = crit_chance;
|
||||||
self.crit_multiplier = crit_multiplier;
|
self.crit_multiplier = crit_multiplier;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_combo_increment(self) -> Self {
|
pub fn with_combo_increment(self) -> Self {
|
||||||
self.with_effect(
|
self.with_effect(
|
||||||
AttackEffect::new(None, CombatEffect::Combo(1))
|
AttackEffect::new(None, CombatEffect::Combo(1))
|
||||||
@ -544,6 +548,7 @@ impl AttackDamage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_effect(mut self, effect: CombatEffect) -> Self {
|
pub fn with_effect(mut self, effect: CombatEffect) -> Self {
|
||||||
self.effects.push(effect);
|
self.effects.push(effect);
|
||||||
self
|
self
|
||||||
@ -568,6 +573,7 @@ impl AttackEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_requirement(mut self, requirement: CombatRequirement) -> Self {
|
pub fn with_requirement(mut self, requirement: CombatRequirement) -> Self {
|
||||||
self.requirements.push(requirement);
|
self.requirements.push(requirement);
|
||||||
self
|
self
|
||||||
@ -806,6 +812,7 @@ impl Knockback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn modify_strength(mut self, power: f32) -> Self {
|
pub fn modify_strength(mut self, power: f32) -> Self {
|
||||||
self.strength *= power;
|
self.strength *= power;
|
||||||
self
|
self
|
||||||
|
@ -673,6 +673,7 @@ impl CharacterAbility {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
|
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
|
||||||
use CharacterAbility::*;
|
use CharacterAbility::*;
|
||||||
match self {
|
match self {
|
||||||
|
@ -126,6 +126,7 @@ impl From<BehaviorCapability> for Behavior {
|
|||||||
impl Behavior {
|
impl Behavior {
|
||||||
/// Builder function
|
/// Builder function
|
||||||
/// Set capabilities if Option is Some
|
/// Set capabilities if Option is Some
|
||||||
|
#[must_use]
|
||||||
pub fn maybe_with_capabilities(
|
pub fn maybe_with_capabilities(
|
||||||
mut self,
|
mut self,
|
||||||
maybe_capabilities: Option<BehaviorCapability>,
|
maybe_capabilities: Option<BehaviorCapability>,
|
||||||
@ -138,6 +139,7 @@ impl Behavior {
|
|||||||
|
|
||||||
/// Builder function
|
/// Builder function
|
||||||
/// Set trade_site if Option is Some
|
/// Set trade_site if Option is Some
|
||||||
|
#[must_use]
|
||||||
pub fn with_trade_site(mut self, trade_site: Option<SiteId>) -> Self {
|
pub fn with_trade_site(mut self, trade_site: Option<SiteId>) -> Self {
|
||||||
self.trade_site = trade_site;
|
self.trade_site = trade_site;
|
||||||
self
|
self
|
||||||
@ -323,6 +325,7 @@ impl Sound {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_new_vol(mut self, new_vol: f32) -> Self {
|
pub fn with_new_vol(mut self, new_vol: f32) -> Self {
|
||||||
self.vol = new_vol;
|
self.vol = new_vol;
|
||||||
|
|
||||||
@ -480,16 +483,19 @@ impl Agent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_patrol_origin(mut self, origin: Vec3<f32>) -> Self {
|
pub fn with_patrol_origin(mut self, origin: Vec3<f32>) -> Self {
|
||||||
self.patrol_origin = Some(origin);
|
self.patrol_origin = Some(origin);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_behavior(mut self, behavior: Behavior) -> Self {
|
pub fn with_behavior(mut self, behavior: Behavior) -> Self {
|
||||||
self.behavior = behavior;
|
self.behavior = behavior;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_no_flee_if(mut self, condition: bool) -> Self {
|
pub fn with_no_flee_if(mut self, condition: bool) -> Self {
|
||||||
if condition {
|
if condition {
|
||||||
self.psyche.flee_health = 0.0;
|
self.psyche.flee_health = 0.0;
|
||||||
@ -498,6 +504,7 @@ impl Agent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Only one of *three* things in this method sets a location.
|
// FIXME: Only one of *three* things in this method sets a location.
|
||||||
|
#[must_use]
|
||||||
pub fn with_destination(mut self, pos: Vec3<f32>) -> Self {
|
pub fn with_destination(mut self, pos: Vec3<f32>) -> Self {
|
||||||
self.psyche.flee_health = 0.0;
|
self.psyche.flee_health = 0.0;
|
||||||
self.rtsim_controller = RtSimController::with_destination(pos);
|
self.rtsim_controller = RtSimController::with_destination(pos);
|
||||||
@ -506,6 +513,7 @@ impl Agent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|
#[must_use]
|
||||||
pub fn with_position_pid_controller(
|
pub fn with_position_pid_controller(
|
||||||
mut self,
|
mut self,
|
||||||
pid: PidController<fn(Vec3<f32>, Vec3<f32>) -> f32, 16>,
|
pid: PidController<fn(Vec3<f32>, Vec3<f32>) -> f32, 16>,
|
||||||
@ -514,6 +522,7 @@ impl Agent {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_aggro_no_warn(mut self) -> Self {
|
pub fn with_aggro_no_warn(mut self) -> Self {
|
||||||
self.psyche.aggro_dist = None;
|
self.psyche.aggro_dist = None;
|
||||||
self
|
self
|
||||||
|
@ -20,7 +20,8 @@ impl LiquidKind {
|
|||||||
/// precedence? (should be a rare edge case, since checkerboard patterns of
|
/// precedence? (should be a rare edge case, since checkerboard patterns of
|
||||||
/// water and lava shouldn't show up in worldgen)
|
/// water and lava shouldn't show up in worldgen)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn merge(self, other: LiquidKind) -> LiquidKind {
|
#[must_use]
|
||||||
|
pub fn merge(self, other: Self) -> Self {
|
||||||
use LiquidKind::{Lava, Water};
|
use LiquidKind::{Lava, Water};
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Water, Water) => Water,
|
(Water, Water) => Water,
|
||||||
|
@ -675,6 +675,7 @@ impl Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Duplicates an item, creating an exact copy but with a new item ID
|
/// Duplicates an item, creating an exact copy but with a new item ID
|
||||||
|
#[must_use]
|
||||||
pub fn duplicate(&self, ability_map: &AbilityMap, msm: &MaterialStatManifest) -> Self {
|
pub fn duplicate(&self, ability_map: &AbilityMap, msm: &MaterialStatManifest) -> Self {
|
||||||
let mut new_item = Item::new_from_item_def(
|
let mut new_item = Item::new_from_item_def(
|
||||||
Arc::clone(&self.item_def),
|
Arc::clone(&self.item_def),
|
||||||
|
@ -105,7 +105,8 @@ impl Stats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clamp_speed(mut self) -> Stats {
|
#[must_use]
|
||||||
|
pub fn clamp_speed(mut self) -> Self {
|
||||||
// if a tool has 0.0 speed, that panics due to being infinite duration, so
|
// if a tool has 0.0 speed, that panics due to being infinite duration, so
|
||||||
// enforce speed >= 0.1 on the final product (but not the intermediates)
|
// enforce speed >= 0.1 on the final product (but not the intermediates)
|
||||||
self.speed = self.speed.max(0.1);
|
self.speed = self.speed.max(0.1);
|
||||||
@ -345,6 +346,7 @@ pub struct AbilitySet<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AbilitySet<AbilityItem> {
|
impl AbilitySet<AbilityItem> {
|
||||||
|
#[must_use]
|
||||||
pub fn modified_by_tool(
|
pub fn modified_by_tool(
|
||||||
self,
|
self,
|
||||||
tool: &Tool,
|
tool: &Tool,
|
||||||
|
@ -62,6 +62,7 @@ impl Ori {
|
|||||||
Self(Quaternion::slerp(ori1.0, ori2.0, s).normalized())
|
Self(Quaternion::slerp(ori1.0, ori2.0, s).normalized())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn slerped_towards(self, ori: Ori, s: f32) -> Self { Self::slerp(self, ori, s) }
|
pub fn slerped_towards(self, ori: Ori, s: f32) -> Self { Self::slerp(self, ori, s) }
|
||||||
|
|
||||||
/// Multiply rotation quaternion by `q`
|
/// Multiply rotation quaternion by `q`
|
||||||
@ -80,6 +81,7 @@ impl Ori {
|
|||||||
///
|
///
|
||||||
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON);
|
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON);
|
||||||
/// ```
|
/// ```
|
||||||
|
#[must_use]
|
||||||
pub fn rotated(self, q: Quaternion<f32>) -> Self {
|
pub fn rotated(self, q: Quaternion<f32>) -> Self {
|
||||||
Self((self.to_quat() * q.normalized()).normalized())
|
Self((self.to_quat() * q.normalized()).normalized())
|
||||||
}
|
}
|
||||||
@ -100,6 +102,7 @@ impl Ori {
|
|||||||
///
|
///
|
||||||
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON);
|
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON);
|
||||||
/// ```
|
/// ```
|
||||||
|
#[must_use]
|
||||||
pub fn prerotated(self, q: Quaternion<f32>) -> Self {
|
pub fn prerotated(self, q: Quaternion<f32>) -> Self {
|
||||||
Self((q.normalized() * self.to_quat()).normalized())
|
Self((q.normalized() * self.to_quat()).normalized())
|
||||||
}
|
}
|
||||||
@ -148,6 +151,7 @@ impl Ori {
|
|||||||
self.to_quat() * local
|
self.to_quat() * local
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn to_horizontal(self) -> Self {
|
pub fn to_horizontal(self) -> Self {
|
||||||
// We don't use Self::look_dir to avoid the extra normalization step within
|
// We don't use Self::look_dir to avoid the extra normalization step within
|
||||||
// Dir's Quaternion Mul impl
|
// Dir's Quaternion Mul impl
|
||||||
@ -210,32 +214,39 @@ impl Ori {
|
|||||||
|
|
||||||
pub fn dot(self, other: Self) -> f32 { self.look_vec().dot(other.look_vec()) }
|
pub fn dot(self, other: Self) -> f32 { self.look_vec().dot(other.look_vec()) }
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn pitched_up(self, angle_radians: f32) -> Self {
|
pub fn pitched_up(self, angle_radians: f32) -> Self {
|
||||||
self.rotated(Quaternion::rotation_x(angle_radians))
|
self.rotated(Quaternion::rotation_x(angle_radians))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn pitched_down(self, angle_radians: f32) -> Self {
|
pub fn pitched_down(self, angle_radians: f32) -> Self {
|
||||||
self.rotated(Quaternion::rotation_x(-angle_radians))
|
self.rotated(Quaternion::rotation_x(-angle_radians))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn yawed_left(self, angle_radians: f32) -> Self {
|
pub fn yawed_left(self, angle_radians: f32) -> Self {
|
||||||
self.rotated(Quaternion::rotation_z(angle_radians))
|
self.rotated(Quaternion::rotation_z(angle_radians))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn yawed_right(self, angle_radians: f32) -> Self {
|
pub fn yawed_right(self, angle_radians: f32) -> Self {
|
||||||
self.rotated(Quaternion::rotation_z(-angle_radians))
|
self.rotated(Quaternion::rotation_z(-angle_radians))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn rolled_left(self, angle_radians: f32) -> Self {
|
pub fn rolled_left(self, angle_radians: f32) -> Self {
|
||||||
self.rotated(Quaternion::rotation_y(-angle_radians))
|
self.rotated(Quaternion::rotation_y(-angle_radians))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn rolled_right(self, angle_radians: f32) -> Self {
|
pub fn rolled_right(self, angle_radians: f32) -> Self {
|
||||||
self.rotated(Quaternion::rotation_y(angle_radians))
|
self.rotated(Quaternion::rotation_y(angle_radians))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a version which is rolled such that its up points towards `dir`
|
/// Returns a version which is rolled such that its up points towards `dir`
|
||||||
/// as much as possible without pitching or yawing
|
/// as much as possible without pitching or yawing
|
||||||
|
#[must_use]
|
||||||
pub fn rolled_towards(self, dir: Dir) -> Self {
|
pub fn rolled_towards(self, dir: Dir) -> Self {
|
||||||
dir.projected(&Plane::from(self.look_dir()))
|
dir.projected(&Plane::from(self.look_dir()))
|
||||||
.map_or(self, |dir| self.prerotated(self.up().rotation_between(dir)))
|
.map_or(self, |dir| self.prerotated(self.up().rotation_between(dir)))
|
||||||
@ -243,6 +254,7 @@ impl Ori {
|
|||||||
|
|
||||||
/// Returns a version which has been pitched towards `dir` as much as
|
/// Returns a version which has been pitched towards `dir` as much as
|
||||||
/// possible without yawing or rolling
|
/// possible without yawing or rolling
|
||||||
|
#[must_use]
|
||||||
pub fn pitched_towards(self, dir: Dir) -> Self {
|
pub fn pitched_towards(self, dir: Dir) -> Self {
|
||||||
dir.projected(&Plane::from(self.right()))
|
dir.projected(&Plane::from(self.right()))
|
||||||
.map_or(self, |dir_| {
|
.map_or(self, |dir_| {
|
||||||
@ -252,6 +264,7 @@ impl Ori {
|
|||||||
|
|
||||||
/// Returns a version which has been yawed towards `dir` as much as possible
|
/// Returns a version which has been yawed towards `dir` as much as possible
|
||||||
/// without pitching or rolling
|
/// without pitching or rolling
|
||||||
|
#[must_use]
|
||||||
pub fn yawed_towards(self, dir: Dir) -> Self {
|
pub fn yawed_towards(self, dir: Dir) -> Self {
|
||||||
dir.projected(&Plane::from(self.up())).map_or(self, |dir_| {
|
dir.projected(&Plane::from(self.up())).map_or(self, |dir_| {
|
||||||
self.prerotated(self.look_dir().rotation_between(dir_))
|
self.prerotated(self.look_dir().rotation_between(dir_))
|
||||||
@ -279,6 +292,7 @@ impl Ori {
|
|||||||
/// let ang2 = pd_rr.up().angle_between(zenith);
|
/// let ang2 = pd_rr.up().angle_between(zenith);
|
||||||
/// assert!((ang1 - ang2).abs() <= std::f32::EPSILON);
|
/// assert!((ang1 - ang2).abs() <= std::f32::EPSILON);
|
||||||
/// ```
|
/// ```
|
||||||
|
#[must_use]
|
||||||
pub fn uprighted(self) -> Self { self.look_dir().into() }
|
pub fn uprighted(self) -> Self { self.look_dir().into() }
|
||||||
|
|
||||||
fn is_normalized(&self) -> bool { self.0.into_vec4().is_normalized() }
|
fn is_normalized(&self) -> bool { self.0.into_vec4().is_normalized() }
|
||||||
|
@ -402,6 +402,7 @@ impl ProjectileConstructor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: split this to three methods per stat
|
// TODO: split this to three methods per stat
|
||||||
|
#[must_use]
|
||||||
pub fn modified_projectile(mut self, power: f32, regen: f32, range: f32) -> Self {
|
pub fn modified_projectile(mut self, power: f32, regen: f32, range: f32) -> Self {
|
||||||
use ProjectileConstructor::*;
|
use ProjectileConstructor::*;
|
||||||
match self {
|
match self {
|
||||||
|
@ -75,7 +75,7 @@ lazy_static! {
|
|||||||
let map = SkillTreeMap::load_expect_cloned(
|
let map = SkillTreeMap::load_expect_cloned(
|
||||||
"common.skill_trees.skills_skill-groups_manifest",
|
"common.skill_trees.skills_skill-groups_manifest",
|
||||||
).0;
|
).0;
|
||||||
map.iter().map(|(sgk, skills)| skills.into_iter().map(move |s| (*s, *sgk))).flatten().collect()
|
map.iter().flat_map(|(sgk, skills)| skills.into_iter().map(move |s| (*s, *sgk))).collect()
|
||||||
};
|
};
|
||||||
// Loads the maximum level that a skill can obtain
|
// Loads the maximum level that a skill can obtain
|
||||||
pub static ref SKILL_MAX_LEVEL: HashMap<Skill, Option<u16>> = {
|
pub static ref SKILL_MAX_LEVEL: HashMap<Skill, Option<u16>> = {
|
||||||
|
@ -81,6 +81,7 @@ impl Segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Transform cells
|
/// Transform cells
|
||||||
|
#[must_use]
|
||||||
pub fn map(mut self, transform: impl Fn(Cell) -> Option<Cell>) -> Self {
|
pub fn map(mut self, transform: impl Fn(Cell) -> Option<Cell>) -> Self {
|
||||||
for pos in self.full_pos_iter() {
|
for pos in self.full_pos_iter() {
|
||||||
if let Some(new) = transform(*self.get(pos).unwrap()) {
|
if let Some(new) = transform(*self.get(pos).unwrap()) {
|
||||||
@ -92,6 +93,7 @@ impl Segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Transform cell colors
|
/// Transform cell colors
|
||||||
|
#[must_use]
|
||||||
pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self {
|
pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self {
|
||||||
self.map(|cell| {
|
self.map(|cell| {
|
||||||
cell.get_color().map(|rgb| {
|
cell.get_color().map(|rgb| {
|
||||||
@ -114,11 +116,13 @@ impl<V: Vox + Copy> DynaUnionizer<V> {
|
|||||||
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
|
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
|
||||||
pub fn new() -> Self { DynaUnionizer(Vec::new()) }
|
pub fn new() -> Self { DynaUnionizer(Vec::new()) }
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn add(mut self, dyna: Dyna<V, ()>, offset: Vec3<i32>) -> Self {
|
pub fn add(mut self, dyna: Dyna<V, ()>, offset: Vec3<i32>) -> Self {
|
||||||
self.0.push((dyna, offset));
|
self.0.push((dyna, offset));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn maybe_add(self, maybe: Option<(Dyna<V, ()>, Vec3<i32>)>) -> Self {
|
pub fn maybe_add(self, maybe: Option<(Dyna<V, ()>, Vec3<i32>)>) -> Self {
|
||||||
match maybe {
|
match maybe {
|
||||||
Some((dyna, offset)) => self.add(dyna, offset),
|
Some((dyna, offset)) => self.add(dyna, offset),
|
||||||
@ -175,6 +179,7 @@ impl MatSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Transform cells
|
/// Transform cells
|
||||||
|
#[must_use]
|
||||||
pub fn map(mut self, transform: impl Fn(MatCell) -> Option<MatCell>) -> Self {
|
pub fn map(mut self, transform: impl Fn(MatCell) -> Option<MatCell>) -> Self {
|
||||||
for pos in self.full_pos_iter() {
|
for pos in self.full_pos_iter() {
|
||||||
if let Some(new) = transform(*self.get(pos).unwrap()) {
|
if let Some(new) = transform(*self.get(pos).unwrap()) {
|
||||||
@ -186,6 +191,7 @@ impl MatSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Transform cell colors
|
/// Transform cell colors
|
||||||
|
#[must_use]
|
||||||
pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self {
|
pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self {
|
||||||
self.map(|cell| match cell {
|
self.map(|cell| match cell {
|
||||||
MatCell::Normal(data) => Some(MatCell::Normal(CellData {
|
MatCell::Normal(data) => Some(MatCell::Normal(CellData {
|
||||||
|
@ -140,6 +140,7 @@ impl EntityConfig {
|
|||||||
.unwrap_or_else(|e| panic!("Failed to load {}. Error: {:?}", asset_specifier, e))
|
.unwrap_or_else(|e| panic!("Failed to load {}. Error: {:?}", asset_specifier, e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_body(mut self, body: BodyBuilder) -> Self {
|
pub fn with_body(mut self, body: BodyBuilder) -> Self {
|
||||||
self.body = body;
|
self.body = body;
|
||||||
|
|
||||||
@ -201,6 +202,7 @@ impl EntityInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function for applying config from asset
|
/// Helper function for applying config from asset
|
||||||
|
#[must_use]
|
||||||
pub fn with_asset_expect(self, asset_specifier: &str) -> Self {
|
pub fn with_asset_expect(self, asset_specifier: &str) -> Self {
|
||||||
let config = EntityConfig::load_expect_cloned(asset_specifier);
|
let config = EntityConfig::load_expect_cloned(asset_specifier);
|
||||||
|
|
||||||
@ -208,6 +210,7 @@ impl EntityInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate and apply EntityConfig
|
/// Evaluate and apply EntityConfig
|
||||||
|
#[must_use]
|
||||||
pub fn with_entity_config(mut self, config: EntityConfig, config_asset: Option<&str>) -> Self {
|
pub fn with_entity_config(mut self, config: EntityConfig, config_asset: Option<&str>) -> Self {
|
||||||
let EntityConfig {
|
let EntityConfig {
|
||||||
name,
|
name,
|
||||||
@ -297,6 +300,7 @@ impl EntityInfo {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn do_if(mut self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self {
|
pub fn do_if(mut self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self {
|
||||||
if cond {
|
if cond {
|
||||||
self = f(self);
|
self = f(self);
|
||||||
@ -304,66 +308,79 @@ impl EntityInfo {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn into_waypoint(mut self) -> Self {
|
pub fn into_waypoint(mut self) -> Self {
|
||||||
self.is_waypoint = true;
|
self.is_waypoint = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_alignment(mut self, alignment: Alignment) -> Self {
|
pub fn with_alignment(mut self, alignment: Alignment) -> Self {
|
||||||
self.alignment = alignment;
|
self.alignment = alignment;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_body(mut self, body: Body) -> Self {
|
pub fn with_body(mut self, body: Body) -> Self {
|
||||||
self.body = body;
|
self.body = body;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_name(mut self, name: impl Into<String>) -> Self {
|
pub fn with_name(mut self, name: impl Into<String>) -> Self {
|
||||||
self.name = Some(name.into());
|
self.name = Some(name.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_agency(mut self, agency: bool) -> Self {
|
pub fn with_agency(mut self, agency: bool) -> Self {
|
||||||
self.has_agency = agency;
|
self.has_agency = agency;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_agent_mark(mut self, agent_mark: agent::Mark) -> Self {
|
pub fn with_agent_mark(mut self, agent_mark: agent::Mark) -> Self {
|
||||||
self.agent_mark = Some(agent_mark);
|
self.agent_mark = Some(agent_mark);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_main_tool(mut self, main_tool: Item) -> Self {
|
pub fn with_main_tool(mut self, main_tool: Item) -> Self {
|
||||||
self.main_tool = Some(main_tool);
|
self.main_tool = Some(main_tool);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_second_tool(mut self, second_tool: Item) -> Self {
|
pub fn with_second_tool(mut self, second_tool: Item) -> Self {
|
||||||
self.second_tool = Some(second_tool);
|
self.second_tool = Some(second_tool);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_loot_drop(mut self, loot_drop: LootSpec<String>) -> Self {
|
pub fn with_loot_drop(mut self, loot_drop: LootSpec<String>) -> Self {
|
||||||
self.loot = loot_drop;
|
self.loot = loot_drop;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_scale(mut self, scale: f32) -> Self {
|
pub fn with_scale(mut self, scale: f32) -> Self {
|
||||||
self.scale = scale;
|
self.scale = scale;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_health_scaling(mut self, level: u16) -> Self {
|
pub fn with_health_scaling(mut self, level: u16) -> Self {
|
||||||
self.health_scaling = Some(level);
|
self.health_scaling = Some(level);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_loadout_asset(mut self, asset: String) -> Self {
|
pub fn with_loadout_asset(mut self, asset: String) -> Self {
|
||||||
self.loadout_asset = Some(asset);
|
self.loadout_asset = Some(asset);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_lazy_loadout(
|
pub fn with_lazy_loadout(
|
||||||
mut self,
|
mut self,
|
||||||
creator: fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder,
|
creator: fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder,
|
||||||
@ -372,11 +389,13 @@ impl EntityInfo {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_skillset_asset(mut self, asset: String) -> Self {
|
pub fn with_skillset_asset(mut self, asset: String) -> Self {
|
||||||
self.skillset_asset = Some(asset);
|
self.skillset_asset = Some(asset);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_automatic_name(mut self) -> Self {
|
pub fn with_automatic_name(mut self) -> Self {
|
||||||
let npc_names = NPC_NAMES.read();
|
let npc_names = NPC_NAMES.read();
|
||||||
let name = match &self.body {
|
let name = match &self.body {
|
||||||
@ -402,7 +421,8 @@ impl EntityInfo {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// map contains price+amount
|
/// map contains price+amount
|
||||||
|
#[must_use]
|
||||||
pub fn with_economy(mut self, e: &SiteInformation) -> Self {
|
pub fn with_economy(mut self, e: &SiteInformation) -> Self {
|
||||||
self.trading_information = Some(e.clone());
|
self.trading_information = Some(e.clone());
|
||||||
self
|
self
|
||||||
|
@ -18,8 +18,7 @@ impl<T> Grid<T> {
|
|||||||
pub fn populate_from(size: Vec2<i32>, mut f: impl FnMut(Vec2<i32>) -> T) -> Self {
|
pub fn populate_from(size: Vec2<i32>, mut f: impl FnMut(Vec2<i32>) -> T) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cells: (0..size.y)
|
cells: (0..size.y)
|
||||||
.map(|y| (0..size.x).map(move |x| Vec2::new(x, y)))
|
.flat_map(|y| (0..size.x).map(move |x| Vec2::new(x, y)))
|
||||||
.flatten()
|
|
||||||
.map(&mut f)
|
.map(&mut f)
|
||||||
.collect(),
|
.collect(),
|
||||||
size,
|
size,
|
||||||
@ -79,8 +78,7 @@ impl<T> Grid<T> {
|
|||||||
pos: Vec2<i32>,
|
pos: Vec2<i32>,
|
||||||
size: Vec2<i32>,
|
size: Vec2<i32>,
|
||||||
) -> impl Iterator<Item = Option<(Vec2<i32>, &T)>> + '_ {
|
) -> impl Iterator<Item = Option<(Vec2<i32>, &T)>> + '_ {
|
||||||
(0..size.x)
|
(0..size.x).flat_map(move |x| {
|
||||||
.map(move |x| {
|
|
||||||
(0..size.y).map(move |y| {
|
(0..size.y).map(move |y| {
|
||||||
Some((
|
Some((
|
||||||
pos + Vec2::new(x, y),
|
pos + Vec2::new(x, y),
|
||||||
@ -88,7 +86,6 @@ impl<T> Grid<T> {
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn raw(&self) -> &[T] { &self.cells }
|
pub fn raw(&self) -> &[T] { &self.cells }
|
||||||
|
@ -248,8 +248,7 @@ impl Route {
|
|||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
(0..2)
|
(0..2)
|
||||||
.map(|i| (0..2).map(move |j| Vec2::new(i, j)))
|
.flat_map(|i| (0..2).map(move |j| Vec2::new(i, j)))
|
||||||
.flatten()
|
|
||||||
.map(|rpos| block_pos + rpos)
|
.map(|rpos| block_pos + rpos)
|
||||||
.map(|block_pos| {
|
.map(|block_pos| {
|
||||||
let block_posf = block_pos.xy().map(|e| e as f32);
|
let block_posf = block_pos.xy().map(|e| e as f32);
|
||||||
|
@ -55,11 +55,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_iter(mut self, max_iter: usize) -> Self {
|
pub fn max_iter(mut self, max_iter: usize) -> Self {
|
||||||
self.max_iter = max_iter;
|
self.max_iter = max_iter;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn ignore_error(mut self) -> Self {
|
pub fn ignore_error(mut self) -> Self {
|
||||||
self.ignore_error = true;
|
self.ignore_error = true;
|
||||||
self
|
self
|
||||||
|
@ -71,6 +71,7 @@ impl Stage<f32> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
|
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
|
||||||
if let Some(CombatEffect::Buff(CombatBuff {
|
if let Some(CombatEffect::Buff(CombatBuff {
|
||||||
kind: _,
|
kind: _,
|
||||||
@ -101,6 +102,7 @@ impl Stage<f32> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: name it as using knockback
|
// TODO: name it as using knockback
|
||||||
|
#[must_use]
|
||||||
pub fn modify_strike(mut self, knockback_mult: f32) -> Self {
|
pub fn modify_strike(mut self, knockback_mult: f32) -> Self {
|
||||||
self.knockback *= knockback_mult;
|
self.knockback *= knockback_mult;
|
||||||
self
|
self
|
||||||
|
@ -341,6 +341,7 @@ impl Block {
|
|||||||
|
|
||||||
/// If this block is a fluid, replace its sprite.
|
/// If this block is a fluid, replace its sprite.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn with_sprite(mut self, sprite: SpriteKind) -> Self {
|
pub fn with_sprite(mut self, sprite: SpriteKind) -> Self {
|
||||||
if !self.is_filled() {
|
if !self.is_filled() {
|
||||||
self.attr[0] = sprite as u8;
|
self.attr[0] = sprite as u8;
|
||||||
@ -350,6 +351,7 @@ impl Block {
|
|||||||
|
|
||||||
/// If this block can have orientation, give it a new orientation.
|
/// If this block can have orientation, give it a new orientation.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn with_ori(mut self, ori: u8) -> Option<Self> {
|
pub fn with_ori(mut self, ori: u8) -> Option<Self> {
|
||||||
if self.get_sprite().map(|s| s.has_ori()).unwrap_or(false) {
|
if self.get_sprite().map(|s| s.has_ori()).unwrap_or(false) {
|
||||||
self.attr[1] = (self.attr[1] & !0b111) | (ori & 0b111);
|
self.attr[1] = (self.attr[1] & !0b111) | (ori & 0b111);
|
||||||
@ -361,6 +363,7 @@ impl Block {
|
|||||||
|
|
||||||
/// Remove the terrain sprite or solid aspects of a block
|
/// Remove the terrain sprite or solid aspects of a block
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn into_vacant(self) -> Self {
|
pub fn into_vacant(self) -> Self {
|
||||||
if self.is_fluid() {
|
if self.is_fluid() {
|
||||||
Block::new(self.kind(), Rgb::zero())
|
Block::new(self.kind(), Rgb::zero())
|
||||||
@ -373,6 +376,7 @@ impl Block {
|
|||||||
|
|
||||||
/// Attempt to convert a [`u32`] to a block
|
/// Attempt to convert a [`u32`] to a block
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn from_u32(x: u32) -> Option<Self> {
|
pub fn from_u32(x: u32) -> Option<Self> {
|
||||||
let [bk, r, g, b] = x.to_le_bytes();
|
let [bk, r, g, b] = x.to_le_bytes();
|
||||||
Some(Self {
|
Some(Self {
|
||||||
|
@ -79,12 +79,11 @@ impl<V, S: RectVolSize, M: Clone> Chonk<V, S, M> {
|
|||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(_, sc)| sc.num_groups() > 0)
|
.filter(|(_, sc)| sc.num_groups() > 0)
|
||||||
.map(move |(i, sc)| {
|
.flat_map(move |(i, sc)| {
|
||||||
let z_offset = self.z_offset + i as i32 * SubChunkSize::<S>::SIZE.z as i32;
|
let z_offset = self.z_offset + i as i32 * SubChunkSize::<S>::SIZE.z as i32;
|
||||||
sc.vol_iter(Vec3::zero(), SubChunkSize::<S>::SIZE.map(|e| e as i32))
|
sc.vol_iter(Vec3::zero(), SubChunkSize::<S>::SIZE.map(|e| e as i32))
|
||||||
.map(move |(pos, vox)| (pos + Vec3::unit_z() * z_offset, vox))
|
.map(move |(pos, vox)| (pos + Vec3::unit_z() * z_offset, vox))
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the index (in self.sub_chunks) of the SubChunk that contains
|
// Returns the index (in self.sub_chunks) of the SubChunk that contains
|
||||||
|
@ -104,6 +104,7 @@ impl Structure {
|
|||||||
StructuresGroup::load_expect(&["world.manifests.", specifier].concat())
|
StructuresGroup::load_expect(&["world.manifests.", specifier].concat())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_center(mut self, center: Vec3<i32>) -> Self {
|
pub fn with_center(mut self, center: Vec3<i32>) -> Self {
|
||||||
self.center = center;
|
self.center = center;
|
||||||
self
|
self
|
||||||
|
@ -363,7 +363,7 @@ impl SitePrices {
|
|||||||
.map(|(slot, amount)| {
|
.map(|(slot, amount)| {
|
||||||
inventories[who]
|
inventories[who]
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|ri| {
|
.and_then(|ri| {
|
||||||
ri.inventory.get(slot).map(|item| {
|
ri.inventory.get(slot).map(|item| {
|
||||||
let (material, factor) = TradePricing::get_material(&item.name);
|
let (material, factor) = TradePricing::get_material(&item.name);
|
||||||
self.values.get(&material).cloned().unwrap_or_default()
|
self.values.get(&material).cloned().unwrap_or_default()
|
||||||
@ -372,7 +372,6 @@ impl SitePrices {
|
|||||||
* if reduce { material.trade_margin() } else { 1.0 }
|
* if reduce { material.trade_margin() } else { 1.0 }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
})
|
})
|
||||||
.sum()
|
.sum()
|
||||||
|
@ -83,6 +83,7 @@ impl Dir {
|
|||||||
Self(slerp_normalized(from.0, to.0, factor))
|
Self(slerp_normalized(from.0, to.0, factor))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn slerped_to(self, to: Self, factor: f32) -> Self {
|
pub fn slerped_to(self, to: Self, factor: f32) -> Self {
|
||||||
Self(slerp_normalized(self.0, to.0, factor))
|
Self(slerp_normalized(self.0, to.0, factor))
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ pub trait Vox: Sized + Clone + PartialEq {
|
|||||||
fn empty() -> Self;
|
fn empty() -> Self;
|
||||||
fn is_empty(&self) -> bool;
|
fn is_empty(&self) -> bool;
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn or(self, other: Self) -> Self { if self.is_empty() { other } else { self } }
|
fn or(self, other: Self) -> Self { if self.is_empty() { other } else { self } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,9 @@ where
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
range_iter(0)
|
range_iter(0)
|
||||||
.map(|i| range_iter(1).map(move |j| range_iter(2).map(move |k| Vec3::new(i, j, k))))
|
.flat_map(|i| {
|
||||||
.flatten()
|
range_iter(1).map(move |j| range_iter(2).map(move |k| Vec3::new(i, j, k)))
|
||||||
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
.map(|offs| self.inner.get(pos + offs))
|
.map(|offs| self.inner.get(pos + offs))
|
||||||
.find(|vox| vox.as_ref().map(|v| !v.is_empty()).unwrap_or(false))
|
.find(|vox| vox.as_ref().map(|v| !v.is_empty()).unwrap_or(false))
|
||||||
|
@ -268,6 +268,7 @@ impl State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Register a component with the state's ECS.
|
/// Register a component with the state's ECS.
|
||||||
|
#[must_use]
|
||||||
pub fn with_component<T: Component>(mut self) -> Self
|
pub fn with_component<T: Component>(mut self) -> Self
|
||||||
where
|
where
|
||||||
<T as Component>::Storage: Default,
|
<T as Component>::Storage: Default,
|
||||||
|
@ -215,19 +215,16 @@ impl<'a> System<'a> for Sys {
|
|||||||
ModifierKind::Additive => *accumulated,
|
ModifierKind::Additive => *accumulated,
|
||||||
ModifierKind::Fractional => health.maximum() * *accumulated,
|
ModifierKind::Fractional => health.maximum() * *accumulated,
|
||||||
};
|
};
|
||||||
let damage_contributor = by
|
let damage_contributor = by.and_then(|uid| {
|
||||||
.map(|uid| {
|
read_data.uid_allocator.retrieve_entity_internal(uid.0).map(
|
||||||
read_data
|
|entity| {
|
||||||
.uid_allocator
|
|
||||||
.retrieve_entity_internal(uid.0)
|
|
||||||
.map(|entity| {
|
|
||||||
DamageContributor::new(
|
DamageContributor::new(
|
||||||
uid,
|
uid,
|
||||||
read_data.groups.get(entity).cloned(),
|
read_data.groups.get(entity).cloned(),
|
||||||
)
|
)
|
||||||
})
|
},
|
||||||
})
|
)
|
||||||
.flatten();
|
});
|
||||||
server_emitter.emit(ServerEvent::HealthChange {
|
server_emitter.emit(ServerEvent::HealthChange {
|
||||||
entity,
|
entity,
|
||||||
change: HealthChange {
|
change: HealthChange {
|
||||||
|
@ -1952,7 +1952,8 @@ fn closest_points(n: LineSegment2<f32>, m: LineSegment2<f32>) -> (Vec2<f32>, Vec
|
|||||||
|
|
||||||
// Check to see whether the lines are parallel
|
// Check to see whether the lines are parallel
|
||||||
if !t.is_finite() || !u.is_finite() {
|
if !t.is_finite() || !u.is_finite() {
|
||||||
core::array::IntoIter::new([
|
// TODO: can use postfix .into_iter() when switching to Rust 2021
|
||||||
|
IntoIterator::into_iter([
|
||||||
(n.projected_point(m.start), m.start),
|
(n.projected_point(m.start), m.start),
|
||||||
(n.projected_point(m.end), m.end),
|
(n.projected_point(m.end), m.end),
|
||||||
(n.start, m.projected_point(n.start)),
|
(n.start, m.projected_point(n.start)),
|
||||||
|
@ -1 +1 @@
|
|||||||
nightly-2021-11-24
|
nightly-2021-12-19
|
||||||
|
@ -471,7 +471,7 @@ fn handle_give_item(
|
|||||||
) -> CmdResult<()> {
|
) -> CmdResult<()> {
|
||||||
if let (Some(item_name), give_amount_opt) = parse_args!(args, String, u32) {
|
if let (Some(item_name), give_amount_opt) = parse_args!(args, String, u32) {
|
||||||
let give_amount = give_amount_opt.unwrap_or(1);
|
let give_amount = give_amount_opt.unwrap_or(1);
|
||||||
if let Ok(item) = Item::new_from_asset(&item_name.replace('/', ".").replace("\\", ".")) {
|
if let Ok(item) = Item::new_from_asset(&item_name.replace('/', ".").replace('\\', ".")) {
|
||||||
let mut item: Item = item;
|
let mut item: Item = item;
|
||||||
let mut res = Ok(());
|
let mut res = Ok(());
|
||||||
|
|
||||||
@ -2805,16 +2805,16 @@ fn handle_disconnect_all_players(
|
|||||||
|
|
||||||
// TODO: This logging and verification of admin commands would be better moved
|
// TODO: This logging and verification of admin commands would be better moved
|
||||||
// to a more generic method used for auditing -all- admin commands.
|
// to a more generic method used for auditing -all- admin commands.
|
||||||
let player_name;
|
|
||||||
if let Some(player) = players.get(client) {
|
let player_name = if let Some(player) = players.get(client) {
|
||||||
player_name = &*player.alias;
|
&*player.alias
|
||||||
} else {
|
} else {
|
||||||
warn!(
|
warn!(
|
||||||
"Failed to get player name for admin who used /disconnect_all_players - ignoring \
|
"Failed to get player name for admin who used /disconnect_all_players - ignoring \
|
||||||
command."
|
command."
|
||||||
);
|
);
|
||||||
return Err("You do not exist, so you cannot use this command".to_string());
|
return Err("You do not exist, so you cannot use this command".to_string());
|
||||||
}
|
};
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Disconnecting all clients due to admin command from {}",
|
"Disconnecting all clients due to admin command from {}",
|
||||||
|
@ -426,15 +426,13 @@ mod tests {
|
|||||||
mockworld.insert(AbilityMap::default());
|
mockworld.insert(AbilityMap::default());
|
||||||
mockworld.register::<Inventory>();
|
mockworld.register::<Inventory>();
|
||||||
mockworld.register::<Uid>();
|
mockworld.register::<Uid>();
|
||||||
let player: EcsEntity;
|
|
||||||
let merchant: EcsEntity;
|
|
||||||
|
|
||||||
player = mockworld
|
let player: EcsEntity = mockworld
|
||||||
.create_entity()
|
.create_entity()
|
||||||
.with(Inventory::new_empty())
|
.with(Inventory::new_empty())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
merchant = mockworld
|
let merchant: EcsEntity = mockworld
|
||||||
.create_entity()
|
.create_entity()
|
||||||
.with(Inventory::new_empty())
|
.with(Inventory::new_empty())
|
||||||
.build();
|
.build();
|
||||||
|
@ -131,13 +131,11 @@ impl StateExt for State {
|
|||||||
let stats = self.ecs().read_storage::<comp::Stats>();
|
let stats = self.ecs().read_storage::<comp::Stats>();
|
||||||
let groups = self.ecs().read_storage::<comp::Group>();
|
let groups = self.ecs().read_storage::<comp::Group>();
|
||||||
|
|
||||||
let damage_contributor = source
|
let damage_contributor = source.and_then(|uid| {
|
||||||
.map(|uid| {
|
|
||||||
self.ecs().entity_from_uid(uid.0).map(|attacker_entity| {
|
self.ecs().entity_from_uid(uid.0).map(|attacker_entity| {
|
||||||
DamageContributor::new(uid, groups.get(attacker_entity).cloned())
|
DamageContributor::new(uid, groups.get(attacker_entity).cloned())
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
.flatten();
|
|
||||||
let time = self.ecs().read_resource::<Time>();
|
let time = self.ecs().read_resource::<Time>();
|
||||||
let change = damage.calculate_health_change(
|
let change = damage.calculate_health_change(
|
||||||
combat::Damage::compute_damage_reduction(
|
combat::Damage::compute_damage_reduction(
|
||||||
@ -612,10 +610,7 @@ impl StateExt for State {
|
|||||||
|
|
||||||
let group_manager = ecs.read_resource::<comp::group::GroupManager>();
|
let group_manager = ecs.read_resource::<comp::group::GroupManager>();
|
||||||
|
|
||||||
let group_info = msg
|
let group_info = msg.get_group().and_then(|g| group_manager.group_info(*g));
|
||||||
.get_group()
|
|
||||||
.map(|g| group_manager.group_info(*g))
|
|
||||||
.flatten();
|
|
||||||
|
|
||||||
let resolved_msg = msg
|
let resolved_msg = msg
|
||||||
.clone()
|
.clone()
|
||||||
|
@ -66,8 +66,7 @@ fn dispatch_circuit_transport<'a>(
|
|||||||
|
|
||||||
(circuits)
|
(circuits)
|
||||||
.join()
|
.join()
|
||||||
.map(|circuit| circuit.wires.iter())
|
.flat_map(|circuit| circuit.wires.iter())
|
||||||
.flatten()
|
|
||||||
.for_each(|wire| {
|
.for_each(|wire| {
|
||||||
let input_value = computed_outputs
|
let input_value = computed_outputs
|
||||||
.get(&wire.input_entity)
|
.get(&wire.input_entity)
|
||||||
|
@ -183,7 +183,7 @@ fn dyn_lib_file(dyn_package: &str, active: bool) -> String {
|
|||||||
format!(
|
format!(
|
||||||
"{}{}{}{}",
|
"{}{}{}{}",
|
||||||
DLL_PREFIX,
|
DLL_PREFIX,
|
||||||
dyn_package.replace("-", "_"),
|
dyn_package.replace('-', "_"),
|
||||||
if active { "_active" } else { "" },
|
if active { "_active" } else { "" },
|
||||||
DLL_SUFFIX
|
DLL_SUFFIX
|
||||||
)
|
)
|
||||||
|
@ -276,8 +276,7 @@ impl<'a> Widget for LootScroller<'a> {
|
|||||||
&& ui
|
&& ui
|
||||||
.widget_graph()
|
.widget_graph()
|
||||||
.widget(state.ids.message_box)
|
.widget(state.ids.message_box)
|
||||||
.map(|w| w.maybe_y_scroll_state)
|
.and_then(|w| w.maybe_y_scroll_state)
|
||||||
.flatten()
|
|
||||||
.map_or(false, |s| s.scrollable_range_len > BOX_HEIGHT)
|
.map_or(false, |s| s.scrollable_range_len > BOX_HEIGHT)
|
||||||
{
|
{
|
||||||
Scrollbar::y_axis(state.ids.message_box)
|
Scrollbar::y_axis(state.ids.message_box)
|
||||||
|
@ -1033,7 +1033,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
} else {
|
} else {
|
||||||
size as f64 / 2.5
|
size as f64 / 2.5
|
||||||
};
|
};
|
||||||
Text::new(&title.to_string())
|
Text::new(title)
|
||||||
.x_y_position_relative_to(
|
.x_y_position_relative_to(
|
||||||
state.ids.map_layers[0],
|
state.ids.map_layers[0],
|
||||||
position::Relative::Scalar(rpos.x as f64),
|
position::Relative::Scalar(rpos.x as f64),
|
||||||
|
@ -243,6 +243,8 @@ impl VoxelMinimap {
|
|||||||
.map2(TerrainChunkSize::RECT_SIZE, |i, j| (i as u32).rem_euclid(j))
|
.map2(TerrainChunkSize::RECT_SIZE, |i, j| (i as u32).rem_euclid(j))
|
||||||
.as_();
|
.as_();
|
||||||
let column = self.chunk_minimaps.get(&(cpos + coff));
|
let column = self.chunk_minimaps.get(&(cpos + coff));
|
||||||
|
// TODO: evaluate clippy, toolchain upgrade 2021-12-19
|
||||||
|
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||||
column
|
column
|
||||||
.map(
|
.map(
|
||||||
|MinimapColumn {
|
|MinimapColumn {
|
||||||
@ -255,7 +257,7 @@ impl VoxelMinimap {
|
|||||||
.and_then(|grid| grid.get(cmod))
|
.and_then(|grid| grid.get(cmod))
|
||||||
.map_or(false, |(_, b)| *b)
|
.map_or(false, |(_, b)| *b)
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(||
|
||||||
// if the `find` returned None, there's no solid blocks above the
|
// if the `find` returned None, there's no solid blocks above the
|
||||||
// player within the chunk
|
// player within the chunk
|
||||||
if above.1 {
|
if above.1 {
|
||||||
@ -269,7 +271,7 @@ impl VoxelMinimap {
|
|||||||
// (subsequent arithmetic on ceiling_offset must be saturating)
|
// (subsequent arithmetic on ceiling_offset must be saturating)
|
||||||
i32::MAX
|
i32::MAX
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
@ -309,6 +311,8 @@ impl VoxelMinimap {
|
|||||||
// the ceiling's height (using the top slice of the chunk if the
|
// the ceiling's height (using the top slice of the chunk if the
|
||||||
// ceiling is above the chunk, (e.g. so that forests with
|
// ceiling is above the chunk, (e.g. so that forests with
|
||||||
// differently-tall trees are handled properly)
|
// differently-tall trees are handled properly)
|
||||||
|
// TODO: evaluate clippy, toolchain upgrade 2021-12-19
|
||||||
|
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||||
layers
|
layers
|
||||||
.get(
|
.get(
|
||||||
(((pos.z as i32 - zlo).saturating_add(ceiling_offset))
|
(((pos.z as i32 - zlo).saturating_add(ceiling_offset))
|
||||||
|
@ -388,6 +388,7 @@ pub enum PositionSpecifier {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub trait Position {
|
pub trait Position {
|
||||||
|
#[must_use]
|
||||||
fn position(self, request: PositionSpecifier) -> Self;
|
fn position(self, request: PositionSpecifier) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ pub struct Quad<V: Vertex> {
|
|||||||
impl<V: Vertex> Quad<V> {
|
impl<V: Vertex> Quad<V> {
|
||||||
pub fn new(a: V, b: V, c: V, d: V) -> Self { Self { a, b, c, d } }
|
pub fn new(a: V, b: V, c: V, d: V) -> Self { Self { a, b, c, d } }
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn rotated_by(self, n: usize) -> Self {
|
pub fn rotated_by(self, n: usize) -> Self {
|
||||||
let verts = [self.a, self.b, self.c, self.d];
|
let verts = [self.a, self.b, self.c, self.d];
|
||||||
|
|
||||||
|
@ -210,6 +210,7 @@ impl Light {
|
|||||||
|
|
||||||
pub fn get_pos(&self) -> Vec3<f32> { Vec3::new(self.pos[0], self.pos[1], self.pos[2]) }
|
pub fn get_pos(&self) -> Vec3<f32> { Vec3::new(self.pos[0], self.pos[1], self.pos[2]) }
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_strength(mut self, strength: f32) -> Self {
|
pub fn with_strength(mut self, strength: f32) -> Self {
|
||||||
self.col = (Vec4::<f32>::from(self.col) * strength).into_array();
|
self.col = (Vec4::<f32>::from(self.col) * strength).into_array();
|
||||||
self
|
self
|
||||||
|
@ -708,7 +708,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
|
|
||||||
let (bias, total) = Spiral2d::new()
|
let (bias, total) = Spiral2d::new()
|
||||||
.take(9)
|
.take(9)
|
||||||
.map(|rpos| {
|
.flat_map(|rpos| {
|
||||||
let chunk_pos = wpos_chunk + rpos;
|
let chunk_pos = wpos_chunk + rpos;
|
||||||
self.chunks
|
self.chunks
|
||||||
.get(&chunk_pos)
|
.get(&chunk_pos)
|
||||||
@ -724,7 +724,6 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
.fold(
|
.fold(
|
||||||
(Vec3::broadcast(0.001), 0.0),
|
(Vec3::broadcast(0.001), 0.0),
|
||||||
|(bias, total), (lpos, level)| {
|
|(bias, total), (lpos, level)| {
|
||||||
|
@ -37,6 +37,7 @@ impl Style {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn hover_image(mut self, image: image::Handle) -> Self {
|
pub fn hover_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
@ -48,6 +49,7 @@ impl Style {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn press_image(mut self, image: image::Handle) -> Self {
|
pub fn press_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
@ -61,6 +63,7 @@ impl Style {
|
|||||||
|
|
||||||
// TODO: this needs to be refactored since the color isn't used if there is no
|
// TODO: this needs to be refactored since the color isn't used if there is no
|
||||||
// background
|
// background
|
||||||
|
#[must_use]
|
||||||
pub fn image_color(mut self, color: Rgba<u8>) -> Self {
|
pub fn image_color(mut self, color: Rgba<u8>) -> Self {
|
||||||
if let Some(background) = &mut self.background {
|
if let Some(background) = &mut self.background {
|
||||||
background.color = color;
|
background.color = color;
|
||||||
@ -68,11 +71,13 @@ impl Style {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn text_color(mut self, color: Color) -> Self {
|
pub fn text_color(mut self, color: Color) -> Self {
|
||||||
self.enabled_text = color;
|
self.enabled_text = color;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn disabled_text_color(mut self, color: Color) -> Self {
|
pub fn disabled_text_color(mut self, color: Color) -> Self {
|
||||||
self.disabled_text = color;
|
self.disabled_text = color;
|
||||||
self
|
self
|
||||||
|
@ -33,6 +33,7 @@ impl Style {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn bg_hover_image(mut self, image: image::Handle) -> Self {
|
pub fn bg_hover_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
@ -44,6 +45,7 @@ impl Style {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn bg_checked_image(mut self, image: image::Handle) -> Self {
|
pub fn bg_checked_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
@ -55,6 +57,7 @@ impl Style {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn bg_hover_checked_image(mut self, image: image::Handle) -> Self {
|
pub fn bg_hover_checked_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
|
@ -46,22 +46,26 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set the ratio (width/height)
|
/// Set the ratio (width/height)
|
||||||
|
#[must_use]
|
||||||
pub fn ratio(mut self, ratio: f32) -> Self {
|
pub fn ratio(mut self, ratio: f32) -> Self {
|
||||||
self.aspect_ratio = AspectRatio::Ratio(ratio);
|
self.aspect_ratio = AspectRatio::Ratio(ratio);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use the ratio of the provided image
|
/// Use the ratio of the provided image
|
||||||
|
#[must_use]
|
||||||
pub fn ratio_of_image(mut self, handle: R::ImageHandle) -> Self {
|
pub fn ratio_of_image(mut self, handle: R::ImageHandle) -> Self {
|
||||||
self.aspect_ratio = AspectRatio::Image(handle);
|
self.aspect_ratio = AspectRatio::Image(handle);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||||
self.max_width = max_width;
|
self.max_width = max_width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_height(mut self, max_height: u32) -> Self {
|
pub fn max_height(mut self, max_height: u32) -> Self {
|
||||||
self.max_height = max_height;
|
self.max_height = max_height;
|
||||||
self
|
self
|
||||||
|
@ -30,32 +30,38 @@ impl Padding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn top(mut self, pad: u16) -> Self {
|
pub fn top(mut self, pad: u16) -> Self {
|
||||||
self.top = pad;
|
self.top = pad;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn bottom(mut self, pad: u16) -> Self {
|
pub fn bottom(mut self, pad: u16) -> Self {
|
||||||
self.bottom = pad;
|
self.bottom = pad;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn right(mut self, pad: u16) -> Self {
|
pub fn right(mut self, pad: u16) -> Self {
|
||||||
self.right = pad;
|
self.right = pad;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn left(mut self, pad: u16) -> Self {
|
pub fn left(mut self, pad: u16) -> Self {
|
||||||
self.left = pad;
|
self.left = pad;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn vertical(mut self, pad: u16) -> Self {
|
pub fn vertical(mut self, pad: u16) -> Self {
|
||||||
self.top = pad;
|
self.top = pad;
|
||||||
self.bottom = pad;
|
self.bottom = pad;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn horizontal(mut self, pad: u16) -> Self {
|
pub fn horizontal(mut self, pad: u16) -> Self {
|
||||||
self.left = pad;
|
self.left = pad;
|
||||||
self.right = pad;
|
self.right = pad;
|
||||||
@ -110,16 +116,19 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn padding(mut self, padding: Padding) -> Self {
|
pub fn padding(mut self, padding: Padding) -> Self {
|
||||||
self.padding = padding;
|
self.padding = padding;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||||
self.max_width = max_width;
|
self.max_width = max_width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_height(mut self, max_height: u32) -> Self {
|
pub fn max_height(mut self, max_height: u32) -> Self {
|
||||||
self.max_height = max_height;
|
self.max_height = max_height;
|
||||||
self
|
self
|
||||||
|
@ -45,6 +45,7 @@ impl Graphic {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn color(mut self, color: Rgba<u8>) -> Self {
|
pub fn color(mut self, color: Rgba<u8>) -> Self {
|
||||||
match &mut self.kind {
|
match &mut self.kind {
|
||||||
GraphicKind::Image(_, c) => *c = color,
|
GraphicKind::Image(_, c) => *c = color,
|
||||||
@ -108,16 +109,19 @@ impl CompoundGraphic {
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn width(mut self, width: Length) -> Self {
|
pub fn width(mut self, width: Length) -> Self {
|
||||||
self.width = width;
|
self.width = width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn height(mut self, height: Length) -> Self {
|
pub fn height(mut self, height: Length) -> Self {
|
||||||
self.height = height;
|
self.height = height;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn fix_aspect_ratio(mut self) -> Self {
|
pub fn fix_aspect_ratio(mut self) -> Self {
|
||||||
self.fix_aspect_ratio = true;
|
self.fix_aspect_ratio = true;
|
||||||
self
|
self
|
||||||
|
@ -36,21 +36,25 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn fill_fraction(mut self, fraction: f32) -> Self {
|
pub fn fill_fraction(mut self, fraction: f32) -> Self {
|
||||||
self.fill_fraction = fraction;
|
self.fill_fraction = fraction;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn vertical_adjustment(mut self, adjustment: f32) -> Self {
|
pub fn vertical_adjustment(mut self, adjustment: f32) -> Self {
|
||||||
self.vertical_adjustment = adjustment;
|
self.vertical_adjustment = adjustment;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn color(mut self, color: impl Into<iced::Color>) -> Self {
|
pub fn color(mut self, color: impl Into<iced::Color>) -> Self {
|
||||||
self.text = self.text.color(color);
|
self.text = self.text.color(color);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn font(mut self, font: impl Into<R::Font>) -> Self {
|
pub fn font(mut self, font: impl Into<R::Font>) -> Self {
|
||||||
self.text = self.text.font(font);
|
self.text = self.text.font(font);
|
||||||
self
|
self
|
||||||
|
@ -30,21 +30,25 @@ impl Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn width(mut self, width: Length) -> Self {
|
pub fn width(mut self, width: Length) -> Self {
|
||||||
self.width = width;
|
self.width = width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn height(mut self, height: Length) -> Self {
|
pub fn height(mut self, height: Length) -> Self {
|
||||||
self.height = height;
|
self.height = height;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn fix_aspect_ratio(mut self) -> Self {
|
pub fn fix_aspect_ratio(mut self) -> Self {
|
||||||
self.fix_aspect_ratio = true;
|
self.fix_aspect_ratio = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn color(mut self, color: Rgba<u8>) -> Self {
|
pub fn color(mut self, color: Rgba<u8>) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
|
@ -44,46 +44,55 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn padding<P: Into<Padding>>(mut self, pad: P) -> Self {
|
pub fn padding<P: Into<Padding>>(mut self, pad: P) -> Self {
|
||||||
self.padding = pad.into();
|
self.padding = pad.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn width(mut self, width: Length) -> Self {
|
pub fn width(mut self, width: Length) -> Self {
|
||||||
self.width = width;
|
self.width = width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn height(mut self, height: Length) -> Self {
|
pub fn height(mut self, height: Length) -> Self {
|
||||||
self.height = height;
|
self.height = height;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||||
self.max_width = max_width;
|
self.max_width = max_width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_height(mut self, max_height: u32) -> Self {
|
pub fn max_height(mut self, max_height: u32) -> Self {
|
||||||
self.max_height = max_height;
|
self.max_height = max_height;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn align_x(mut self, align_x: Align) -> Self {
|
pub fn align_x(mut self, align_x: Align) -> Self {
|
||||||
self.horizontal_alignment = align_x;
|
self.horizontal_alignment = align_x;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn align_y(mut self, align_y: Align) -> Self {
|
pub fn align_y(mut self, align_y: Align) -> Self {
|
||||||
self.vertical_alignment = align_y;
|
self.vertical_alignment = align_y;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn center_x(mut self) -> Self {
|
pub fn center_x(mut self) -> Self {
|
||||||
self.horizontal_alignment = Align::Center;
|
self.horizontal_alignment = Align::Center;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn center_y(mut self) -> Self {
|
pub fn center_y(mut self) -> Self {
|
||||||
self.vertical_alignment = Align::Center;
|
self.vertical_alignment = Align::Center;
|
||||||
self
|
self
|
||||||
|
@ -419,6 +419,7 @@ impl<'a> ItemTooltip<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Specify the font used for displaying the text.
|
/// Specify the font used for displaying the text.
|
||||||
|
#[must_use]
|
||||||
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
|
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
|
||||||
self.style.title.font_id = Some(Some(font_id));
|
self.style.title.font_id = Some(Some(font_id));
|
||||||
self.style.desc.font_id = Some(Some(font_id));
|
self.style.desc.font_id = Some(Some(font_id));
|
||||||
@ -1211,7 +1212,7 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
|
|
||||||
// Stats
|
// Stats
|
||||||
let stat_h = if util::stats_count(self.item) > 0 {
|
let stat_h = if util::stats_count(self.item) > 0 {
|
||||||
widget::Text::new(&"placeholder".to_string())
|
widget::Text::new("placeholder")
|
||||||
.with_style(self.style.desc)
|
.with_style(self.style.desc)
|
||||||
.get_h(ui)
|
.get_h(ui)
|
||||||
.unwrap_or(0.0)
|
.unwrap_or(0.0)
|
||||||
|
@ -49,6 +49,7 @@ impl<'a> OutlinedText<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
|
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
|
||||||
self.text_style.font_id = Some(Some(font_id));
|
self.text_style.font_id = Some(Some(font_id));
|
||||||
self
|
self
|
||||||
|
@ -71,30 +71,35 @@ impl<'a, T> RadioList<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn source_rectangle(mut self, rect: Rect) -> Self {
|
pub fn source_rectangle(mut self, rect: Rect) -> Self {
|
||||||
self.f_image.src_rect = Some(rect);
|
self.f_image.src_rect = Some(rect);
|
||||||
self.t_image.src_rect = Some(rect);
|
self.t_image.src_rect = Some(rect);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn image_colors(mut self, f_color: Color, t_color: Color) -> Self {
|
pub fn image_colors(mut self, f_color: Color, t_color: Color) -> Self {
|
||||||
self.f_image.color = button::ImageColor::Normal(f_color);
|
self.f_image.color = button::ImageColor::Normal(f_color);
|
||||||
self.t_image.color = button::ImageColor::Normal(t_color);
|
self.t_image.color = button::ImageColor::Normal(t_color);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn image_color_with_feedback(mut self, f_color: Color, t_color: Color) -> Self {
|
pub fn image_color_with_feedback(mut self, f_color: Color, t_color: Color) -> Self {
|
||||||
self.f_image.color = button::ImageColor::WithFeedback(f_color);
|
self.f_image.color = button::ImageColor::WithFeedback(f_color);
|
||||||
self.t_image.color = button::ImageColor::WithFeedback(t_color);
|
self.t_image.color = button::ImageColor::WithFeedback(t_color);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn hover_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
pub fn hover_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
||||||
self.f_image.hover_image_id = Some(f_id);
|
self.f_image.hover_image_id = Some(f_id);
|
||||||
self.t_image.hover_image_id = Some(t_id);
|
self.t_image.hover_image_id = Some(t_id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn press_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
pub fn press_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
||||||
self.f_image.press_image_id = Some(f_id);
|
self.f_image.press_image_id = Some(f_id);
|
||||||
self.t_image.press_image_id = Some(t_id);
|
self.t_image.press_image_id = Some(t_id);
|
||||||
|
@ -499,16 +499,19 @@ where
|
|||||||
pub with_background_color { background_color = Some(Color) }
|
pub with_background_color { background_color = Some(Color) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_manager(mut self, slot_manager: &'a mut SlotManager<S>) -> Self {
|
pub fn with_manager(mut self, slot_manager: &'a mut SlotManager<S>) -> Self {
|
||||||
self.slot_manager = Some(slot_manager);
|
self.slot_manager = Some(slot_manager);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn filled_slot(mut self, img: image::Id) -> Self {
|
pub fn filled_slot(mut self, img: image::Id) -> Self {
|
||||||
self.filled_slot = img;
|
self.filled_slot = img;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn with_icon(mut self, img: image::Id, size: Vec2<f32>, color: Option<Color>) -> Self {
|
pub fn with_icon(mut self, img: image::Id, size: Vec2<f32>, color: Option<Color>) -> Self {
|
||||||
self.icon = Some((img, size, color));
|
self.icon = Some((img, size, color));
|
||||||
self
|
self
|
||||||
|
@ -45,30 +45,35 @@ impl ToggleButton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn source_rectangle(mut self, rect: Rect) -> Self {
|
pub fn source_rectangle(mut self, rect: Rect) -> Self {
|
||||||
self.f_image.src_rect = Some(rect);
|
self.f_image.src_rect = Some(rect);
|
||||||
self.t_image.src_rect = Some(rect);
|
self.t_image.src_rect = Some(rect);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn image_colors(mut self, f_color: Color, t_color: Color) -> Self {
|
pub fn image_colors(mut self, f_color: Color, t_color: Color) -> Self {
|
||||||
self.f_image.color = button::ImageColor::Normal(f_color);
|
self.f_image.color = button::ImageColor::Normal(f_color);
|
||||||
self.t_image.color = button::ImageColor::Normal(t_color);
|
self.t_image.color = button::ImageColor::Normal(t_color);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn image_color_with_feedback(mut self, f_color: Color, t_color: Color) -> Self {
|
pub fn image_color_with_feedback(mut self, f_color: Color, t_color: Color) -> Self {
|
||||||
self.f_image.color = button::ImageColor::WithFeedback(f_color);
|
self.f_image.color = button::ImageColor::WithFeedback(f_color);
|
||||||
self.t_image.color = button::ImageColor::WithFeedback(t_color);
|
self.t_image.color = button::ImageColor::WithFeedback(t_color);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn hover_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
pub fn hover_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
||||||
self.f_image.hover_image_id = Some(f_id);
|
self.f_image.hover_image_id = Some(f_id);
|
||||||
self.t_image.hover_image_id = Some(t_id);
|
self.t_image.hover_image_id = Some(t_id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn press_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
pub fn press_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
|
||||||
self.f_image.press_image_id = Some(f_id);
|
self.f_image.press_image_id = Some(f_id);
|
||||||
self.t_image.press_image_id = Some(t_id);
|
self.t_image.press_image_id = Some(t_id);
|
||||||
|
@ -348,6 +348,7 @@ impl<'a> Tooltip<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Specify the font used for displaying the text.
|
/// Specify the font used for displaying the text.
|
||||||
|
#[must_use]
|
||||||
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
|
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
|
||||||
self.style.title.font_id = Some(Some(font_id));
|
self.style.title.font_id = Some(Some(font_id));
|
||||||
self.style.desc.font_id = Some(Some(font_id));
|
self.style.desc.font_id = Some(Some(font_id));
|
||||||
|
@ -5,13 +5,13 @@ use veloren_world::site::economy::{self, good_list, Economy};
|
|||||||
|
|
||||||
fn good_name(g: Good) -> String {
|
fn good_name(g: Good) -> String {
|
||||||
let res = format!("{:?}", g);
|
let res = format!("{:?}", g);
|
||||||
let res = res.replace("(", "_");
|
let res = res.replace('(', "_");
|
||||||
res.replace(")", "_")
|
res.replace(')', "_")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn labor_name(l: economy::Labor) -> String {
|
fn labor_name(l: economy::Labor) -> String {
|
||||||
let res = format!("{:?}", l);
|
let res = format!("{:?}", l);
|
||||||
res.replace(" ", "_")
|
res.replace(' ', "_")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), std::io::Error> {
|
fn main() -> Result<(), std::io::Error> {
|
||||||
|
@ -44,8 +44,7 @@ impl<'a> CanvasInfo<'a> {
|
|||||||
pub fn col(&self, wpos: Vec2<i32>) -> Option<&'a ColumnSample> {
|
pub fn col(&self, wpos: Vec2<i32>) -> Option<&'a ColumnSample> {
|
||||||
self.column_grid
|
self.column_grid
|
||||||
.get(self.column_grid_border + wpos - self.wpos())
|
.get(self.column_grid_border + wpos - self.wpos())
|
||||||
.map(Option::as_ref)
|
.and_then(Option::as_ref)
|
||||||
.flatten()
|
|
||||||
.map(|zc| &zc.sample)
|
.map(|zc| &zc.sample)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +66,7 @@ impl<'a> CanvasInfo<'a> {
|
|||||||
/// spot, seed)`.
|
/// spot, seed)`.
|
||||||
pub fn nearby_spots(&self) -> impl Iterator<Item = (Vec2<i32>, Spot, u32)> + '_ {
|
pub fn nearby_spots(&self) -> impl Iterator<Item = (Vec2<i32>, Spot, u32)> + '_ {
|
||||||
(-1..2)
|
(-1..2)
|
||||||
.map(|x| (-1..2).map(move |y| Vec2::new(x, y)))
|
.flat_map(|x| (-1..2).map(move |y| Vec2::new(x, y)))
|
||||||
.flatten()
|
|
||||||
.filter_map(move |pos| {
|
.filter_map(move |pos| {
|
||||||
let pos = self.chunk_pos + pos;
|
let pos = self.chunk_pos + pos;
|
||||||
self.chunks.get(pos).and_then(|c| c.spot).map(|spot| {
|
self.chunks.get(pos).and_then(|c| c.spot).map(|spot| {
|
||||||
|
@ -35,7 +35,7 @@ pub fn apply_shrubs_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
|
|||||||
|
|
||||||
let info = canvas.info();
|
let info = canvas.info();
|
||||||
canvas.foreach_col(|_, wpos2d, _| {
|
canvas.foreach_col(|_, wpos2d, _| {
|
||||||
for (wpos, seed) in std::array::IntoIter::new(shrub_gen.get(wpos2d)) {
|
for (wpos, seed) in shrub_gen.get(wpos2d) {
|
||||||
shrub_cache.entry(wpos).or_insert_with(|| {
|
shrub_cache.entry(wpos).or_insert_with(|| {
|
||||||
let col = info.col_or_gen(wpos)?;
|
let col = info.col_or_gen(wpos)?;
|
||||||
|
|
||||||
|
@ -164,13 +164,12 @@ impl World {
|
|||||||
self.civs()
|
self.civs()
|
||||||
.caves
|
.caves
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(id, info)| {
|
.flat_map(|(id, info)| {
|
||||||
// separate the two locations, combine with name
|
// separate the two locations, combine with name
|
||||||
std::iter::once((id.id() + num_sites, info.name.clone(), info.location.0))
|
std::iter::once((id.id() + num_sites, info.name.clone(), info.location.0))
|
||||||
// unfortunately we have to introduce a fake id (as it gets stored in a map in the client)
|
// unfortunately we have to introduce a fake id (as it gets stored in a map in the client)
|
||||||
.chain(std::iter::once((id.id() + num_sites + num_caves, info.name.clone(), info.location.1)))
|
.chain(std::iter::once((id.id() + num_sites + num_caves, info.name.clone(), info.location.1)))
|
||||||
})
|
}) // unwrap inner iteration
|
||||||
.flatten() // unwrap inner iteration
|
|
||||||
.map(|(id, name, pos)| world_msg::SiteInfo {
|
.map(|(id, name, pos)| world_msg::SiteInfo {
|
||||||
id,
|
id,
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
@ -335,8 +334,7 @@ impl World {
|
|||||||
let sample_get = |offs| {
|
let sample_get = |offs| {
|
||||||
zcache_grid
|
zcache_grid
|
||||||
.get(grid_border + offs)
|
.get(grid_border + offs)
|
||||||
.map(Option::as_ref)
|
.and_then(Option::as_ref)
|
||||||
.flatten()
|
|
||||||
.map(|zc| &zc.sample)
|
.map(|zc| &zc.sample)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ use rayon::prelude::*;
|
|||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
*/
|
*/
|
||||||
|
#[allow(clippy::needless_late_init)]
|
||||||
pub fn diffusion(
|
pub fn diffusion(
|
||||||
nx: usize,
|
nx: usize,
|
||||||
ny: usize,
|
ny: usize,
|
||||||
@ -404,6 +405,7 @@ pub fn diffusion(
|
|||||||
INTEGER n
|
INTEGER n
|
||||||
double precision a(n),b(n),c(n),r(n),u(n)
|
double precision a(n),b(n),c(n),r(n),u(n)
|
||||||
*/
|
*/
|
||||||
|
#[allow(clippy::needless_late_init)]
|
||||||
pub fn tridag(a: &[f64], b: &[f64], c: &[f64], r: &[f64], u: &mut [f64], n: usize) {
|
pub fn tridag(a: &[f64], b: &[f64], c: &[f64], r: &[f64], u: &mut [f64], n: usize) {
|
||||||
/*
|
/*
|
||||||
INTEGER j
|
INTEGER j
|
||||||
|
@ -138,8 +138,7 @@ pub fn sample_pos(
|
|||||||
.and_then(|samples| {
|
.and_then(|samples| {
|
||||||
chunk_idx
|
chunk_idx
|
||||||
.and_then(|chunk_idx| samples.get(chunk_idx))
|
.and_then(|chunk_idx| samples.get(chunk_idx))
|
||||||
.map(Option::as_ref)
|
.and_then(Option::as_ref)
|
||||||
.flatten()
|
|
||||||
})
|
})
|
||||||
.map(|sample| {
|
.map(|sample| {
|
||||||
// TODO: Eliminate the redundancy between this and the block renderer.
|
// TODO: Eliminate the redundancy between this and the block renderer.
|
||||||
|
@ -1731,12 +1731,11 @@ impl WorldSim {
|
|||||||
let this = &self;
|
let this = &self;
|
||||||
let waypoints = (0..this.map_size_lg().chunks().x)
|
let waypoints = (0..this.map_size_lg().chunks().x)
|
||||||
.step_by(WAYPOINT_EVERY)
|
.step_by(WAYPOINT_EVERY)
|
||||||
.map(|i| {
|
.flat_map(|i| {
|
||||||
(0..this.map_size_lg().chunks().y)
|
(0..this.map_size_lg().chunks().y)
|
||||||
.step_by(WAYPOINT_EVERY)
|
.step_by(WAYPOINT_EVERY)
|
||||||
.map(move |j| (i, j))
|
.map(move |j| (i, j))
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.filter_map(|(i, j)| {
|
.filter_map(|(i, j)| {
|
||||||
@ -2130,7 +2129,8 @@ impl WorldSim {
|
|||||||
/// them spawning).
|
/// them spawning).
|
||||||
pub fn get_near_trees(&self, wpos: Vec2<i32>) -> impl Iterator<Item = TreeAttr> + '_ {
|
pub fn get_near_trees(&self, wpos: Vec2<i32>) -> impl Iterator<Item = TreeAttr> + '_ {
|
||||||
// Deterministic based on wpos
|
// Deterministic based on wpos
|
||||||
let normal_trees = std::array::IntoIter::new(self.gen_ctx.structure_gen.get(wpos))
|
// TODO: can use postfix .into_iter() when switching to Rust 2021
|
||||||
|
let normal_trees = IntoIterator::into_iter(self.gen_ctx.structure_gen.get(wpos))
|
||||||
.filter_map(move |(wpos, seed)| {
|
.filter_map(move |(wpos, seed)| {
|
||||||
let lottery = self.make_forest_lottery(wpos);
|
let lottery = self.make_forest_lottery(wpos);
|
||||||
Some(TreeAttr {
|
Some(TreeAttr {
|
||||||
|
@ -1278,8 +1278,7 @@ mod tests {
|
|||||||
let mut neighbors: Vec<crate::site::economy::NeighborInformation> = e
|
let mut neighbors: Vec<crate::site::economy::NeighborInformation> = e
|
||||||
.neighbors
|
.neighbors
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(nid, dist)| index.sites.recreate_id(*nid).map(|i| (i, dist)))
|
.flat_map(|(nid, dist)| index.sites.recreate_id(*nid).map(|i| (i, dist)))
|
||||||
.flatten()
|
|
||||||
.map(|(nid, dist)| crate::site::economy::NeighborInformation {
|
.map(|(nid, dist)| crate::site::economy::NeighborInformation {
|
||||||
id: nid,
|
id: nid,
|
||||||
travel_distance: *dist,
|
travel_distance: *dist,
|
||||||
|
@ -21,11 +21,13 @@ impl BlockMask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn with_priority(mut self, priority: i32) -> Self {
|
pub const fn with_priority(mut self, priority: i32) -> Self {
|
||||||
self.priority = priority;
|
self.priority = priority;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn resolve_with(self, other: Self) -> Self {
|
pub const fn resolve_with(self, other: Self) -> Self {
|
||||||
if self.priority >= other.priority {
|
if self.priority >= other.priority {
|
||||||
self
|
self
|
||||||
|
@ -207,8 +207,7 @@ impl Archetype for House {
|
|||||||
border: 4,
|
border: 4,
|
||||||
children: [1, -1]
|
children: [1, -1]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|flip| (0..branches_per_side).map(move |i| (i, *flip)))
|
.flat_map(|flip| (0..branches_per_side).map(move |i| (i, *flip)))
|
||||||
.flatten()
|
|
||||||
.filter_map(|(i, flip)| {
|
.filter_map(|(i, flip)| {
|
||||||
if rng.gen() {
|
if rng.gen() {
|
||||||
Some((
|
Some((
|
||||||
|
@ -8,6 +8,7 @@ pub enum Ori {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Ori {
|
impl Ori {
|
||||||
|
#[must_use]
|
||||||
pub fn flip(self) -> Self {
|
pub fn flip(self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Ori::East => Ori::North,
|
Ori::East => Ori::North,
|
||||||
|
@ -217,8 +217,7 @@ impl Settlement {
|
|||||||
let wpos = self.origin + tile * AREA_SIZE as i32;
|
let wpos = self.origin + tile * AREA_SIZE as i32;
|
||||||
|
|
||||||
if (0..4)
|
if (0..4)
|
||||||
.map(|x| (0..4).map(move |y| Vec2::new(x, y)))
|
.flat_map(|x| (0..4).map(move |y| Vec2::new(x, y)))
|
||||||
.flatten()
|
|
||||||
.any(|offs| {
|
.any(|offs| {
|
||||||
let wpos = wpos + offs * AREA_SIZE as i32 / 2;
|
let wpos = wpos + offs * AREA_SIZE as i32 / 2;
|
||||||
let cpos = wpos.map(|e| e.div_euclid(TerrainChunkSize::RECT_SIZE.x as i32));
|
let cpos = wpos.map(|e| e.div_euclid(TerrainChunkSize::RECT_SIZE.x as i32));
|
||||||
@ -446,7 +445,7 @@ impl Settlement {
|
|||||||
StructureKind::House(Building::<House>::generate(
|
StructureKind::House(Building::<House>::generate(
|
||||||
ctx.rng,
|
ctx.rng,
|
||||||
Vec3::new(house_pos.x, house_pos.y, alt),
|
Vec3::new(house_pos.x, house_pos.y, alt),
|
||||||
ctx.sim.map(|sim| sim.calendar.as_ref()).flatten(),
|
ctx.sim.and_then(|sim| sim.calendar.as_ref()),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -667,12 +667,10 @@ impl Site {
|
|||||||
let tile = self.tiles.get(tpos);
|
let tile = self.tiles.get(tpos);
|
||||||
let twpos = self.tile_wpos(tpos);
|
let twpos = self.tile_wpos(tpos);
|
||||||
let border = TILE_SIZE as i32;
|
let border = TILE_SIZE as i32;
|
||||||
let cols = (-border..TILE_SIZE as i32 + border)
|
let cols = (-border..TILE_SIZE as i32 + border).flat_map(|y| {
|
||||||
.map(|y| {
|
|
||||||
(-border..TILE_SIZE as i32 + border)
|
(-border..TILE_SIZE as i32 + border)
|
||||||
.map(move |x| (twpos + Vec2::new(x, y), Vec2::new(x, y)))
|
.map(move |x| (twpos + Vec2::new(x, y), Vec2::new(x, y)))
|
||||||
})
|
});
|
||||||
.flatten();
|
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match &tile.kind {
|
match &tile.kind {
|
||||||
@ -930,8 +928,7 @@ fn wpos_is_hazard(land: &Land, wpos: Vec2<i32>) -> Option<HazardKind> {
|
|||||||
|
|
||||||
pub fn aabr_tiles(aabr: Aabr<i32>) -> impl Iterator<Item = Vec2<i32>> {
|
pub fn aabr_tiles(aabr: Aabr<i32>) -> impl Iterator<Item = Vec2<i32>> {
|
||||||
(0..aabr.size().h)
|
(0..aabr.size().h)
|
||||||
.map(move |y| (0..aabr.size().w).map(move |x| aabr.min + Vec2::new(x, y)))
|
.flat_map(move |y| (0..aabr.size().w).map(move |x| aabr.min + Vec2::new(x, y)))
|
||||||
.flatten()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Plaza {}
|
pub struct Plaza {}
|
||||||
|
Loading…
Reference in New Issue
Block a user