Merge branch 'joedonofry/dropped_lantern_glow' into 'master'

Add glow to dropped lanterns

See merge request veloren/veloren!3772
This commit is contained in:
Joshua Barretto 2023-01-23 16:13:43 +00:00
commit 88ac238121
5 changed files with 18 additions and 5 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Command to toggle experimental shaders.
- Faster Energy Regeneration while sitting.
- Lantern glow for dropped lanterns.
### Changed
- Bats move slower and use a simple proportional controller to maintain altitude

View File

@ -61,6 +61,8 @@ impl Lantern {
pub fn strength(&self) -> f32 { self.strength_thousandths as f32 / 1000_f32 }
pub fn color(&self) -> Rgb<f32> { self.color.map(|c| c as f32 / 255.0) }
pub fn flicker(&self) -> f32 { self.flicker_thousandths as f32 / 1000_f32 }
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Copy, PartialOrd, Ord)]

View File

@ -57,18 +57,18 @@ pub fn handle_lantern(server: &mut Server, entity: EcsEntity, enable: bool) {
.and_then(|inventory| inventory.equipped(EquipSlot::Lantern))
.and_then(|item| {
if let comp::item::ItemKind::Lantern(l) = &*item.kind() {
Some((l.color(), l.strength()))
Some((l.color(), l.strength(), l.flicker()))
} else {
None
}
});
if let Some((col, strength)) = lantern_info {
if let Some((col, strength, flicker)) = lantern_info {
let _ =
ecs.write_storage::<comp::LightEmitter>()
.insert(entity, comp::LightEmitter {
col,
strength,
flicker: 0.35,
flicker,
animated: true,
});
}

View File

@ -16,7 +16,7 @@ use common::{
combat::DamageContributor,
comp::{
self,
item::MaterialStatManifest,
item::{ItemKind, MaterialStatManifest},
skills::{GeneralSkill, Skill},
ChatType, Group, Inventory, Item, Player, Poise,
},
@ -299,6 +299,15 @@ impl StateExt for State {
fn create_item_drop(&mut self, pos: comp::Pos, item: Item) -> EcsEntityBuilder {
let item_drop = comp::item_drop::Body::from(&item);
let body = comp::Body::ItemDrop(item_drop);
let light_emitter = match &*item.kind() {
ItemKind::Lantern(lantern) => Some(comp::LightEmitter {
col: lantern.color(),
strength: lantern.strength(),
flicker: lantern.flicker(),
animated: true,
}),
_ => None,
};
self.ecs_mut()
.create_entity_synced()
.with(item)
@ -309,6 +318,7 @@ impl StateExt for State {
.with(item_drop.density())
.with(body.collider())
.with(body)
.maybe_with(light_emitter)
}
fn create_ship<F: FnOnce(comp::ship::Body) -> comp::Collider>(

View File

@ -35,7 +35,7 @@ impl Skeleton for ItemDropSkeleton {
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) =
[make_bone(bone0_mat)];
Offsets {
lantern: None,
lantern: Some((bone0_mat * Vec4::new(0.0, 0.0, 3.5, 1.0)).xyz()),
viewpoint: None,
mount_bone: Transform {
position: comp::Body::ItemDrop(body)