mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Eradicated clones
This commit is contained in:
parent
9f2255a5de
commit
6a1e583d45
@ -896,8 +896,7 @@ impl Client {
|
|||||||
.write_storage::<Controller>()
|
.write_storage::<Controller>()
|
||||||
.get_mut(self.entity)
|
.get_mut(self.entity)
|
||||||
{
|
{
|
||||||
// TODO: Undo this clone, somehow...
|
controller.actions.push(control_action);
|
||||||
controller.actions.push(control_action.clone());
|
|
||||||
}
|
}
|
||||||
self.send_msg(ClientGeneral::ControlAction(control_action));
|
self.send_msg(ClientGeneral::ControlAction(control_action));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
combat::Attack,
|
combat::Attack,
|
||||||
comp::{Energy, InventoryManip, Ori, Pos, Vel},
|
comp::{Energy, LoadoutManip, Ori, Pos, Vel},
|
||||||
event::{LocalEvent, ServerEvent},
|
event::{LocalEvent, ServerEvent},
|
||||||
states::{behavior::JoinData, *},
|
states::{behavior::JoinData, *},
|
||||||
};
|
};
|
||||||
@ -17,7 +17,7 @@ pub struct StateUpdate {
|
|||||||
pub ori: Ori,
|
pub ori: Ori,
|
||||||
pub energy: Energy,
|
pub energy: Energy,
|
||||||
pub swap_loadout: bool,
|
pub swap_loadout: bool,
|
||||||
pub modify_loadout: Option<InventoryManip>,
|
pub modify_loadout: Option<LoadoutManip>,
|
||||||
pub local_events: VecDeque<LocalEvent>,
|
pub local_events: VecDeque<LocalEvent>,
|
||||||
pub server_events: VecDeque<ServerEvent>,
|
pub server_events: VecDeque<ServerEvent>,
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,31 @@ pub enum InventoryManip {
|
|||||||
CraftRecipe(String),
|
CraftRecipe(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub enum LoadoutManip {
|
||||||
|
Swap(Slot, Slot),
|
||||||
|
Drop(Slot),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<LoadoutManip> for InventoryManip {
|
||||||
|
fn from(loadout_manip: LoadoutManip) -> Self {
|
||||||
|
match loadout_manip {
|
||||||
|
LoadoutManip::Swap(slot1, slot2) => Self::Swap(slot1, slot2),
|
||||||
|
LoadoutManip::Drop(slot) => Self::Drop(slot),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<InventoryManip> for Option<LoadoutManip> {
|
||||||
|
fn from(inv_manip: InventoryManip) -> Self {
|
||||||
|
match inv_manip {
|
||||||
|
InventoryManip::Swap(slot1, slot2) => Some(LoadoutManip::Swap(slot1, slot2)),
|
||||||
|
InventoryManip::Drop(slot) => Some(LoadoutManip::Drop(slot)),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum GroupManip {
|
pub enum GroupManip {
|
||||||
Invite(Uid),
|
Invite(Uid),
|
||||||
@ -46,10 +71,10 @@ pub enum ControlEvent {
|
|||||||
Respawn,
|
Respawn,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum ControlAction {
|
pub enum ControlAction {
|
||||||
SwapLoadout,
|
SwapLoadout,
|
||||||
ModifyLoadout(InventoryManip),
|
ModifyLoadout(Option<LoadoutManip>),
|
||||||
Wield,
|
Wield,
|
||||||
GlideWield,
|
GlideWield,
|
||||||
Unwield,
|
Unwield,
|
||||||
|
@ -46,7 +46,7 @@ pub use chat::{
|
|||||||
};
|
};
|
||||||
pub use controller::{
|
pub use controller::{
|
||||||
Climb, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip, Input,
|
Climb, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip, Input,
|
||||||
InventoryManip, MountState, Mounting,
|
InventoryManip, LoadoutManip, MountState, Mounting,
|
||||||
};
|
};
|
||||||
pub use energy::{Energy, EnergyChange, EnergySource};
|
pub use energy::{Energy, EnergyChange, EnergySource};
|
||||||
pub use group::Group;
|
pub use group::Group;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
Beam, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy, Health,
|
Beam, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy, Health,
|
||||||
Inventory, InventoryManip, Melee, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel,
|
Inventory, LoadoutManip, Melee, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel,
|
||||||
},
|
},
|
||||||
resources::DeltaTime,
|
resources::DeltaTime,
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
@ -17,7 +17,7 @@ pub trait CharacterBehavior {
|
|||||||
fn behavior(&self, data: &JoinData) -> StateUpdate;
|
fn behavior(&self, data: &JoinData) -> StateUpdate;
|
||||||
// Impl these to provide behavior for these inputs
|
// Impl these to provide behavior for these inputs
|
||||||
fn swap_loadout(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
fn swap_loadout(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||||
fn modify_loadout(&self, data: &JoinData, _inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, _loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
StateUpdate::from(data)
|
StateUpdate::from(data)
|
||||||
}
|
}
|
||||||
fn wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
fn wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||||
@ -31,7 +31,7 @@ pub trait CharacterBehavior {
|
|||||||
fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate {
|
fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate {
|
||||||
match event {
|
match event {
|
||||||
ControlAction::SwapLoadout => self.swap_loadout(data),
|
ControlAction::SwapLoadout => self.swap_loadout(data),
|
||||||
ControlAction::ModifyLoadout(inv_manip) => self.modify_loadout(data, inv_manip),
|
ControlAction::ModifyLoadout(loadout_manip) => self.modify_loadout(data, loadout_manip),
|
||||||
ControlAction::Wield => self.wield(data),
|
ControlAction::Wield => self.wield(data),
|
||||||
ControlAction::GlideWield => self.glide_wield(data),
|
ControlAction::GlideWield => self.glide_wield(data),
|
||||||
ControlAction::Unwield => self.unwield(data),
|
ControlAction::Unwield => self.unwield(data),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, InventoryManip, StateUpdate},
|
comp::{CharacterState, LoadoutManip, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -42,9 +42,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn modify_loadout(&self, data: &JoinData, inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_modify_loadout(&mut update, inv_manip);
|
handle_modify_loadout(&mut update, loadout_manip);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{slot::EquipSlot, CharacterState, EnergySource, InventoryManip, StateUpdate},
|
comp::{slot::EquipSlot, CharacterState, EnergySource, LoadoutManip, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,9 +69,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn modify_loadout(&self, data: &JoinData, inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_modify_loadout(&mut update, inv_manip);
|
handle_modify_loadout(&mut update, loadout_manip);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{InventoryManip, StateUpdate},
|
comp::{LoadoutManip, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn modify_loadout(&self, data: &JoinData, inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_modify_loadout(&mut update, inv_manip);
|
handle_modify_loadout(&mut update, loadout_manip);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, InventoryManip, StateUpdate},
|
comp::{CharacterState, LoadoutManip, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -42,9 +42,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn modify_loadout(&self, data: &JoinData, inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_modify_loadout(&mut update, inv_manip);
|
handle_modify_loadout(&mut update, loadout_manip);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, InventoryManip, StateUpdate},
|
comp::{CharacterState, LoadoutManip, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,9 +60,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn modify_loadout(&self, data: &JoinData, inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_modify_loadout(&mut update, inv_manip);
|
handle_modify_loadout(&mut update, loadout_manip);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, InventoryManip, StateUpdate},
|
comp::{CharacterState, LoadoutManip, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -47,9 +47,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn modify_loadout(&self, data: &JoinData, inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_modify_loadout(&mut update, inv_manip);
|
handle_modify_loadout(&mut update, loadout_manip);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use crate::{
|
|||||||
item::{Hands, ItemKind, Tool, ToolKind},
|
item::{Hands, ItemKind, Tool, ToolKind},
|
||||||
quadruped_low, quadruped_medium,
|
quadruped_low, quadruped_medium,
|
||||||
skills::{AxeSkill, BowSkill, HammerSkill, Skill, StaffSkill, SwordSkill},
|
skills::{AxeSkill, BowSkill, HammerSkill, Skill, StaffSkill, SwordSkill},
|
||||||
theropod, Body, CharacterState, InventoryManip, StateUpdate,
|
theropod, Body, CharacterState, LoadoutManip, StateUpdate,
|
||||||
},
|
},
|
||||||
consts::{FRIC_GROUND, GRAVITY},
|
consts::{FRIC_GROUND, GRAVITY},
|
||||||
event::LocalEvent,
|
event::LocalEvent,
|
||||||
@ -360,8 +360,8 @@ pub fn attempt_swap_loadout(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handles inventory manipulations that affect the loadout
|
/// Handles inventory manipulations that affect the loadout
|
||||||
pub fn handle_modify_loadout(update: &mut StateUpdate, inv_manip: InventoryManip) {
|
pub fn handle_modify_loadout(update: &mut StateUpdate, loadout_manip: Option<LoadoutManip>) {
|
||||||
update.modify_loadout = Some(inv_manip);
|
update.modify_loadout = loadout_manip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that player can wield the glider and updates `CharacterState` if so
|
/// Checks that player can wield the glider and updates `CharacterState` if so
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, InventoryManip, StateUpdate},
|
comp::{CharacterState, LoadoutManip, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,9 +57,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn modify_loadout(&self, data: &JoinData, inv_manip: InventoryManip) -> StateUpdate {
|
fn modify_loadout(&self, data: &JoinData, loadout_manip: Option<LoadoutManip>) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_modify_loadout(&mut update, inv_manip);
|
handle_modify_loadout(&mut update, loadout_manip);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,9 +268,9 @@ impl<'a> System<'a> for Sys {
|
|||||||
};
|
};
|
||||||
local_emitter.append(&mut state_update.local_events);
|
local_emitter.append(&mut state_update.local_events);
|
||||||
server_emitter.append(&mut state_update.server_events);
|
server_emitter.append(&mut state_update.server_events);
|
||||||
if let Some(ref inv_manip) = state_update.modify_loadout {
|
if let Some(loadout_manip) = state_update.modify_loadout {
|
||||||
// TODO: Delete this clone, somehow...
|
server_emitter
|
||||||
server_emitter.emit(ServerEvent::InventoryManip(j.entity, inv_manip.clone()));
|
.emit(ServerEvent::InventoryManip(j.entity, loadout_manip.into()));
|
||||||
}
|
}
|
||||||
incorporate_update(&mut tuple, state_update);
|
incorporate_update(&mut tuple, state_update);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,9 @@ impl<'a> System<'a> for Sys {
|
|||||||
InventoryManip::Drop(Slot::Equip(_))
|
InventoryManip::Drop(Slot::Equip(_))
|
||||||
| InventoryManip::Swap(_, Slot::Equip(_))
|
| InventoryManip::Swap(_, Slot::Equip(_))
|
||||||
| InventoryManip::Swap(Slot::Equip(_), _) => {
|
| InventoryManip::Swap(Slot::Equip(_), _) => {
|
||||||
controller.actions.push(ControlAction::ModifyLoadout(manip));
|
controller
|
||||||
|
.actions
|
||||||
|
.push(ControlAction::ModifyLoadout(manip.into()));
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
server_emitter.emit(ServerEvent::InventoryManip(entity, manip));
|
server_emitter.emit(ServerEvent::InventoryManip(entity, manip));
|
||||||
|
Loading…
Reference in New Issue
Block a user