mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Switched to using existing swap_lantern
function
Removed unnecessary function
This commit is contained in:
parent
889a593b13
commit
64f6faece5
@ -72,7 +72,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
server_emitter.emit(ServerEvent::DisableLantern(entity))
|
server_emitter.emit(ServerEvent::DisableLantern(entity))
|
||||||
},
|
},
|
||||||
ControlEvent::UpdateLantern(lantern) => {
|
ControlEvent::UpdateLantern(lantern) => {
|
||||||
server_emitter.emit(ServerEvent::UpdateLantern(entity, 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
|
||||||
|
@ -35,19 +35,6 @@ 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,9 +15,9 @@ 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, update_lantern,
|
handle_possess, handle_sound, handle_unmount,
|
||||||
};
|
};
|
||||||
use inventory_manip::handle_inventory;
|
use inventory_manip::{handle_inventory, swap_lantern};
|
||||||
use invite::{handle_invite, handle_invite_response};
|
use invite::{handle_invite, handle_invite_response};
|
||||||
use player::{handle_client_disconnect, handle_exit_ingame};
|
use player::{handle_client_disconnect, handle_exit_ingame};
|
||||||
use specs::{Builder, Entity as EcsEntity, WorldExt};
|
use specs::{Builder, Entity as EcsEntity, WorldExt};
|
||||||
@ -107,9 +107,14 @@ 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) => {
|
ServerEvent::UpdateLantern(entity, lantern) => swap_lantern(
|
||||||
update_lantern(self, entity, lantern)
|
&mut self
|
||||||
},
|
.state
|
||||||
|
.ecs()
|
||||||
|
.write_storage::<common::comp::LightEmitter>(),
|
||||||
|
entity,
|
||||||
|
&lantern,
|
||||||
|
),
|
||||||
ServerEvent::NpcInteract(interactor, target) => {
|
ServerEvent::NpcInteract(interactor, target) => {
|
||||||
handle_npc_interaction(self, interactor, target)
|
handle_npc_interaction(self, interactor, target)
|
||||||
},
|
},
|
||||||
|
@ -1234,7 +1234,7 @@ 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;
|
let mut lantern_opt: Option<comp::item::Lantern> = None;
|
||||||
if !bypass_dialog {
|
if !bypass_dialog {
|
||||||
if let Some(inventory) = self
|
if let Some(inventory) = self
|
||||||
.client
|
.client
|
||||||
@ -1248,7 +1248,7 @@ impl PlayState for SessionState {
|
|||||||
(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 {
|
if let EquipSlot::Lantern = equip_slot {
|
||||||
maybe_lantern =
|
lantern_opt =
|
||||||
inventory.get(inv_slot).and_then(|item| {
|
inventory.get(inv_slot).and_then(|item| {
|
||||||
if let comp::item::ItemKind::Lantern(l) =
|
if let comp::item::ItemKind::Lantern(l) =
|
||||||
item.kind()
|
item.kind()
|
||||||
@ -1289,10 +1289,10 @@ 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);
|
||||||
|
if let Some(lantern) = lantern_opt {
|
||||||
|
self.client.borrow_mut().update_lantern(lantern)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
HudEvent::SplitSwapSlots {
|
HudEvent::SplitSwapSlots {
|
||||||
|
Loading…
Reference in New Issue
Block a user