mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
hang wreaths at the fireplace
This commit is contained in:
parent
9b485456eb
commit
c0b56671ec
@ -149,7 +149,12 @@ fn profession_agent_mark(profession: Option<&Profession>) -> Option<comp::agent:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_npc_entity_info(npc: &Npc, sites: &Sites, index: IndexRef, time: Option<&(TimeOfDay, Calendar)>) -> EntityInfo {
|
fn get_npc_entity_info(
|
||||||
|
npc: &Npc,
|
||||||
|
sites: &Sites,
|
||||||
|
index: IndexRef,
|
||||||
|
time: Option<&(TimeOfDay, Calendar)>,
|
||||||
|
) -> EntityInfo {
|
||||||
let pos = comp::Pos(npc.wpos);
|
let pos = comp::Pos(npc.wpos);
|
||||||
|
|
||||||
let mut rng = npc.rng(Npc::PERM_ENTITY_CONFIG);
|
let mut rng = npc.rng(Npc::PERM_ENTITY_CONFIG);
|
||||||
@ -321,7 +326,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let entity_info = get_npc_entity_info(npc, &data.sites, index.as_index_ref(), Some(&calendar_data));
|
let entity_info = get_npc_entity_info(
|
||||||
|
npc,
|
||||||
|
&data.sites,
|
||||||
|
index.as_index_ref(),
|
||||||
|
Some(&calendar_data),
|
||||||
|
);
|
||||||
|
|
||||||
emitter.emit(match NpcData::from_entity_info(entity_info) {
|
emitter.emit(match NpcData::from_entity_info(entity_info) {
|
||||||
NpcData::Data {
|
NpcData::Data {
|
||||||
@ -377,8 +387,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
let npc = data.npcs.npcs.get_mut(npc_id)?;
|
let npc = data.npcs.npcs.get_mut(npc_id)?;
|
||||||
if matches!(npc.mode, SimulationMode::Simulated) {
|
if matches!(npc.mode, SimulationMode::Simulated) {
|
||||||
npc.mode = SimulationMode::Loaded;
|
npc.mode = SimulationMode::Loaded;
|
||||||
let entity_info =
|
let entity_info = get_npc_entity_info(
|
||||||
get_npc_entity_info(npc, &data.sites, index.as_index_ref(), Some(&calendar_data));
|
npc,
|
||||||
|
&data.sites,
|
||||||
|
index.as_index_ref(),
|
||||||
|
Some(&calendar_data),
|
||||||
|
);
|
||||||
|
|
||||||
Some(match NpcData::from_entity_info(entity_info) {
|
Some(match NpcData::from_entity_info(entity_info) {
|
||||||
NpcData::Data {
|
NpcData::Data {
|
||||||
|
@ -13,6 +13,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
astar::Astar,
|
astar::Astar,
|
||||||
|
calendar::Calendar,
|
||||||
path::Path,
|
path::Path,
|
||||||
spiral::Spiral2d,
|
spiral::Spiral2d,
|
||||||
store::{Id, Store},
|
store::{Id, Store},
|
||||||
@ -236,6 +237,7 @@ impl Civs {
|
|||||||
seed: u32,
|
seed: u32,
|
||||||
sim: &mut WorldSim,
|
sim: &mut WorldSim,
|
||||||
index: &mut Index,
|
index: &mut Index,
|
||||||
|
calendar: Option<&Calendar>,
|
||||||
report_stage: &dyn Fn(WorldCivStage),
|
report_stage: &dyn Fn(WorldCivStage),
|
||||||
) -> Self {
|
) -> Self {
|
||||||
prof_span!("Civs::generate");
|
prof_span!("Civs::generate");
|
||||||
@ -543,6 +545,7 @@ impl Civs {
|
|||||||
&mut rng,
|
&mut rng,
|
||||||
wpos,
|
wpos,
|
||||||
size,
|
size,
|
||||||
|
calendar,
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
SiteKind::CliffTown => WorldSite::cliff_town(site2::Site::generate_cliff_town(
|
SiteKind::CliffTown => WorldSite::cliff_town(site2::Site::generate_cliff_town(
|
||||||
|
@ -128,12 +128,14 @@ impl World {
|
|||||||
// is broken.
|
// is broken.
|
||||||
threadpool.install(|| {
|
threadpool.install(|| {
|
||||||
let mut index = Index::new(seed);
|
let mut index = Index::new(seed);
|
||||||
|
let calendar = opts.calendar.clone();
|
||||||
|
|
||||||
let mut sim = sim::WorldSim::generate(seed, opts, threadpool, &|stage| {
|
let mut sim = sim::WorldSim::generate(seed, opts, threadpool, &|stage| {
|
||||||
report_stage(WorldGenerateStage::WorldSimGenerate(stage))
|
report_stage(WorldGenerateStage::WorldSimGenerate(stage))
|
||||||
});
|
});
|
||||||
|
|
||||||
let civs = civ::Civs::generate(seed, &mut sim, &mut index, &|stage| {
|
let civs =
|
||||||
|
civ::Civs::generate(seed, &mut sim, &mut index, calendar.as_ref(), &|stage| {
|
||||||
report_stage(WorldGenerateStage::WorldCivGenerate(stage))
|
report_stage(WorldGenerateStage::WorldCivGenerate(stage))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
astar::Astar,
|
astar::Astar,
|
||||||
|
calendar::Calendar,
|
||||||
comp::Alignment,
|
comp::Alignment,
|
||||||
generation::EntityInfo,
|
generation::EntityInfo,
|
||||||
lottery::Lottery,
|
lottery::Lottery,
|
||||||
@ -579,6 +580,7 @@ impl Site {
|
|||||||
rng: &mut impl Rng,
|
rng: &mut impl Rng,
|
||||||
origin: Vec2<i32>,
|
origin: Vec2<i32>,
|
||||||
size: f32,
|
size: f32,
|
||||||
|
calendar: Option<&Calendar>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut rng = reseed(rng);
|
let mut rng = reseed(rng);
|
||||||
|
|
||||||
@ -664,6 +666,7 @@ impl Site {
|
|||||||
door_tile,
|
door_tile,
|
||||||
door_dir,
|
door_dir,
|
||||||
aabr,
|
aabr,
|
||||||
|
calendar,
|
||||||
);
|
);
|
||||||
let house_alt = house.alt;
|
let house_alt = house.alt;
|
||||||
let plot = site.create_plot(Plot {
|
let plot = site.create_plot(Plot {
|
||||||
@ -2023,6 +2026,7 @@ pub fn test_site() -> Site {
|
|||||||
&mut thread_rng(),
|
&mut thread_rng(),
|
||||||
Vec2::zero(),
|
Vec2::zero(),
|
||||||
0.5,
|
0.5,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,10 @@ use crate::{
|
|||||||
util::{RandomField, Sampler, DIRS},
|
util::{RandomField, Sampler, DIRS},
|
||||||
Land,
|
Land,
|
||||||
};
|
};
|
||||||
use common::terrain::{Block, BlockKind, SpriteKind};
|
use common::{
|
||||||
|
calendar::{Calendar, CalendarEvent},
|
||||||
|
terrain::{Block, BlockKind, SpriteKind},
|
||||||
|
};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -25,6 +28,7 @@ pub struct House {
|
|||||||
/// Color of the roof
|
/// Color of the roof
|
||||||
roof_color: Rgb<u8>,
|
roof_color: Rgb<u8>,
|
||||||
front: u8,
|
front: u8,
|
||||||
|
christmas_decorations: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl House {
|
impl House {
|
||||||
@ -35,6 +39,7 @@ impl House {
|
|||||||
door_tile: Vec2<i32>,
|
door_tile: Vec2<i32>,
|
||||||
door_dir: Vec2<i32>,
|
door_dir: Vec2<i32>,
|
||||||
tile_aabr: Aabr<i32>,
|
tile_aabr: Aabr<i32>,
|
||||||
|
calendar: Option<&Calendar>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let levels = rng.gen_range(1..2 + (tile_aabr.max - tile_aabr.min).product() / 6) as u32;
|
let levels = rng.gen_range(1..2 + (tile_aabr.max - tile_aabr.min).product() / 6) as u32;
|
||||||
let door_tile_pos = site.tile_center_wpos(door_tile);
|
let door_tile_pos = site.tile_center_wpos(door_tile);
|
||||||
@ -52,6 +57,8 @@ impl House {
|
|||||||
} else {
|
} else {
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
|
let christmas_decorations =
|
||||||
|
calendar.map_or(false, |c| c.is_event(CalendarEvent::Christmas));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
door_tile: door_tile_pos,
|
door_tile: door_tile_pos,
|
||||||
@ -83,6 +90,7 @@ impl House {
|
|||||||
*colors.choose(rng).unwrap_or(&Rgb::new(21, 43, 48))
|
*colors.choose(rng).unwrap_or(&Rgb::new(21, 43, 48))
|
||||||
},
|
},
|
||||||
front,
|
front,
|
||||||
|
christmas_decorations,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2041,6 +2049,52 @@ impl Structure for House {
|
|||||||
painter.prim(Primitive::Aabb(fire_embers)),
|
painter.prim(Primitive::Aabb(fire_embers)),
|
||||||
Fill::Block(Block::air(SpriteKind::Ember)),
|
Fill::Block(Block::air(SpriteKind::Ember)),
|
||||||
);
|
);
|
||||||
|
if self.christmas_decorations {
|
||||||
|
let (wreath_pos, wreath_ori) = match self.front {
|
||||||
|
0 => (
|
||||||
|
Aabb {
|
||||||
|
min: Vec2::new(fireplace_origin.x + 1, fireplace_origin.y + 3)
|
||||||
|
.with_z(alt + 2),
|
||||||
|
max: Vec2::new(fireplace_origin.x + 2, fireplace_origin.y + 4)
|
||||||
|
.with_z(alt + 3),
|
||||||
|
},
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
1 => (
|
||||||
|
Aabb {
|
||||||
|
min: Vec2::new(fireplace_origin.x + 3, fireplace_origin.y + 1)
|
||||||
|
.with_z(alt + 2),
|
||||||
|
max: Vec2::new(fireplace_origin.x + 4, fireplace_origin.y + 2)
|
||||||
|
.with_z(alt + 3),
|
||||||
|
},
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
2 => (
|
||||||
|
Aabb {
|
||||||
|
min: Vec2::new(fireplace_origin.x + 1, fireplace_origin.y - 1)
|
||||||
|
.with_z(alt + 2),
|
||||||
|
max: Vec2::new(fireplace_origin.x + 2, fireplace_origin.y).with_z(alt + 3),
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
_ => (
|
||||||
|
Aabb {
|
||||||
|
min: Vec2::new(fireplace_origin.x - 1, fireplace_origin.y + 1)
|
||||||
|
.with_z(alt + 2),
|
||||||
|
max: Vec2::new(fireplace_origin.x, fireplace_origin.y + 2).with_z(alt + 3),
|
||||||
|
},
|
||||||
|
6,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
painter.fill(
|
||||||
|
painter.prim(Primitive::Aabb(wreath_pos)),
|
||||||
|
Fill::Block(
|
||||||
|
Block::air(SpriteKind::ChristmasWreath)
|
||||||
|
.with_ori(wreath_ori)
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Door
|
// Door
|
||||||
// Fill around the door with wall
|
// Fill around the door with wall
|
||||||
|
Loading…
Reference in New Issue
Block a user