diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e331cb3f1..02f1c43df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 3111c4d1e8..88ebec582f 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -61,6 +61,8 @@ impl Lantern { pub fn strength(&self) -> f32 { self.strength_thousandths as f32 / 1000_f32 } pub fn color(&self) -> Rgb { 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)] diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index f04d910219..0aad278d92 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -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::() .insert(entity, comp::LightEmitter { col, strength, - flicker: 0.35, + flicker, animated: true, }); } diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 8c83130b18..940bc1802f 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -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 comp::Collider>( diff --git a/voxygen/anim/src/item_drop/mod.rs b/voxygen/anim/src/item_drop/mod.rs index beb139c150..918b06860d 100644 --- a/voxygen/anim/src/item_drop/mod.rs +++ b/voxygen/anim/src/item_drop/mod.rs @@ -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)