mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Lantern color will now change when swapping lanterns while lantern is activated
This commit is contained in:
parent
7b7ad62be9
commit
fc012b4989
@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Bodies of water no longer contain black chunks on the voxel minimap.
|
- Bodies of water no longer contain black chunks on the voxel minimap.
|
||||||
- Agents can flee once again, and more appropriately
|
- Agents can flee once again, and more appropriately
|
||||||
- Items in hotbar no longer change when sorting inventory
|
- Items in hotbar no longer change when sorting inventory
|
||||||
|
- Lantern color changes when swapping lanterns
|
||||||
|
|
||||||
## [0.11.0] - 2021-09-11
|
## [0.11.0] - 2021-09-11
|
||||||
|
|
||||||
|
@ -1081,6 +1081,12 @@ impl Client {
|
|||||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::DisableLantern));
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::DisableLantern));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_lantern(&mut self, lantern: comp::item::Lantern) {
|
||||||
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::UpdateLantern(
|
||||||
|
lantern,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn remove_buff(&mut self, buff_id: BuffKind) {
|
pub fn remove_buff(&mut self, buff_id: BuffKind) {
|
||||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::RemoveBuff(
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::RemoveBuff(
|
||||||
buff_id,
|
buff_id,
|
||||||
|
@ -125,6 +125,7 @@ pub enum ControlEvent {
|
|||||||
//ToggleLantern,
|
//ToggleLantern,
|
||||||
EnableLantern,
|
EnableLantern,
|
||||||
DisableLantern,
|
DisableLantern,
|
||||||
|
UpdateLantern(crate::comp::item::Lantern),
|
||||||
Interact(Uid),
|
Interact(Uid),
|
||||||
InitiateInvite(Uid, InviteKind),
|
InitiateInvite(Uid, InviteKind),
|
||||||
InviteResponse(InviteResponse),
|
InviteResponse(InviteResponse),
|
||||||
|
@ -93,6 +93,7 @@ pub enum ServerEvent {
|
|||||||
},
|
},
|
||||||
EnableLantern(EcsEntity),
|
EnableLantern(EcsEntity),
|
||||||
DisableLantern(EcsEntity),
|
DisableLantern(EcsEntity),
|
||||||
|
UpdateLantern(EcsEntity, comp::item::Lantern),
|
||||||
NpcInteract(EcsEntity, EcsEntity),
|
NpcInteract(EcsEntity, EcsEntity),
|
||||||
InviteResponse(EcsEntity, InviteResponse),
|
InviteResponse(EcsEntity, InviteResponse),
|
||||||
InitiateInvite(EcsEntity, Uid, InviteKind),
|
InitiateInvite(EcsEntity, Uid, InviteKind),
|
||||||
|
@ -71,6 +71,9 @@ impl<'a> System<'a> for Sys {
|
|||||||
ControlEvent::DisableLantern => {
|
ControlEvent::DisableLantern => {
|
||||||
server_emitter.emit(ServerEvent::DisableLantern(entity))
|
server_emitter.emit(ServerEvent::DisableLantern(entity))
|
||||||
},
|
},
|
||||||
|
ControlEvent::UpdateLantern(lantern) => {
|
||||||
|
server_emitter.emit(ServerEvent::UpdateLantern(entity, lantern));
|
||||||
|
},
|
||||||
ControlEvent::Interact(npc_uid) => {
|
ControlEvent::Interact(npc_uid) => {
|
||||||
if let Some(npc_entity) = read_data
|
if let Some(npc_entity) = read_data
|
||||||
.uid_allocator
|
.uid_allocator
|
||||||
|
@ -35,6 +35,19 @@ use lazy_static::lazy_static;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
|
||||||
|
pub fn update_lantern(server: &mut Server, entity: EcsEntity, lantern: comp::item::Lantern){
|
||||||
|
let _ = server
|
||||||
|
.state_mut()
|
||||||
|
.ecs()
|
||||||
|
.write_storage::<comp::LightEmitter>()
|
||||||
|
.insert(entity, comp::LightEmitter{
|
||||||
|
col: lantern.color(),
|
||||||
|
strength: lantern.strength(),
|
||||||
|
flicker: 0.35,
|
||||||
|
animated: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handle_lantern(server: &mut Server, entity: EcsEntity, enable: bool) {
|
pub fn handle_lantern(server: &mut Server, entity: EcsEntity, enable: bool) {
|
||||||
let ecs = server.state_mut().ecs();
|
let ecs = server.state_mut().ecs();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use group_manip::handle_group;
|
|||||||
use information::handle_site_info;
|
use information::handle_site_info;
|
||||||
use interaction::{
|
use interaction::{
|
||||||
handle_create_sprite, handle_lantern, handle_mine_block, handle_mount, handle_npc_interaction,
|
handle_create_sprite, handle_lantern, handle_mine_block, handle_mount, handle_npc_interaction,
|
||||||
handle_possess, handle_sound, handle_unmount,
|
handle_possess, handle_sound, handle_unmount, update_lantern,
|
||||||
};
|
};
|
||||||
use inventory_manip::handle_inventory;
|
use inventory_manip::handle_inventory;
|
||||||
use invite::{handle_invite, handle_invite_response};
|
use invite::{handle_invite, handle_invite_response};
|
||||||
@ -107,6 +107,9 @@ impl Server {
|
|||||||
},
|
},
|
||||||
ServerEvent::EnableLantern(entity) => handle_lantern(self, entity, true),
|
ServerEvent::EnableLantern(entity) => handle_lantern(self, entity, true),
|
||||||
ServerEvent::DisableLantern(entity) => handle_lantern(self, entity, false),
|
ServerEvent::DisableLantern(entity) => handle_lantern(self, entity, false),
|
||||||
|
ServerEvent::UpdateLantern(entity, lantern) => {
|
||||||
|
update_lantern(self, entity, lantern)
|
||||||
|
},
|
||||||
ServerEvent::NpcInteract(interactor, target) => {
|
ServerEvent::NpcInteract(interactor, target) => {
|
||||||
handle_npc_interaction(self, interactor, target)
|
handle_npc_interaction(self, interactor, target)
|
||||||
},
|
},
|
||||||
|
@ -1234,9 +1234,9 @@ impl PlayState for SessionState {
|
|||||||
bypass_dialog,
|
bypass_dialog,
|
||||||
} => {
|
} => {
|
||||||
let mut move_allowed = true;
|
let mut move_allowed = true;
|
||||||
|
let mut maybe_lantern: Option<comp::item::Lantern> = None;
|
||||||
if !bypass_dialog {
|
if !bypass_dialog {
|
||||||
if let Some(inventory) = self
|
if let Some(inventory) = self.client
|
||||||
.client
|
|
||||||
.borrow()
|
.borrow()
|
||||||
.state()
|
.state()
|
||||||
.ecs()
|
.ecs()
|
||||||
@ -1246,6 +1246,18 @@ impl PlayState for SessionState {
|
|||||||
match (slot_a, slot_b) {
|
match (slot_a, slot_b) {
|
||||||
(Slot::Inventory(inv_slot), Slot::Equip(equip_slot))
|
(Slot::Inventory(inv_slot), Slot::Equip(equip_slot))
|
||||||
| (Slot::Equip(equip_slot), Slot::Inventory(inv_slot)) => {
|
| (Slot::Equip(equip_slot), Slot::Inventory(inv_slot)) => {
|
||||||
|
if let EquipSlot::Lantern = equip_slot {
|
||||||
|
maybe_lantern =
|
||||||
|
inventory.get(inv_slot).and_then(|item| {
|
||||||
|
if let comp::item::ItemKind::Lantern(l) =
|
||||||
|
item.kind()
|
||||||
|
{
|
||||||
|
Some(l.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if !inventory.can_swap(inv_slot, equip_slot) {
|
if !inventory.can_swap(inv_slot, equip_slot) {
|
||||||
move_allowed = false;
|
move_allowed = false;
|
||||||
} else {
|
} else {
|
||||||
@ -1276,6 +1288,9 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if move_allowed {
|
if move_allowed {
|
||||||
|
if let Some(new_lantern) = maybe_lantern {
|
||||||
|
self.client.borrow_mut().update_lantern(new_lantern);
|
||||||
|
}
|
||||||
self.client.borrow_mut().swap_slots(slot_a, slot_b);
|
self.client.borrow_mut().swap_slots(slot_a, slot_b);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user