mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'sam/item-use-as-action' into 'master'
Item use is now goes through a control action rather than a control event. Closes #979 See merge request veloren/veloren!1839
This commit is contained in:
commit
f16c137635
@ -27,7 +27,7 @@ use common::{
|
|||||||
skills::Skill,
|
skills::Skill,
|
||||||
slot::Slot,
|
slot::Slot,
|
||||||
ChatMode, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip,
|
ChatMode, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip,
|
||||||
InventoryManip, InventoryUpdateEvent, LoadoutManip,
|
InventoryAction, InventoryEvent, InventoryUpdateEvent,
|
||||||
},
|
},
|
||||||
event::{EventBus, LocalEvent},
|
event::{EventBus, LocalEvent},
|
||||||
grid::Grid,
|
grid::Grid,
|
||||||
@ -621,24 +621,17 @@ impl Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn use_slot(&mut self, slot: Slot) {
|
pub fn use_slot(&mut self, slot: Slot) {
|
||||||
match slot {
|
self.control_action(ControlAction::InventoryAction(InventoryAction::Use(slot)))
|
||||||
Slot::Equip(equip) => {
|
|
||||||
self.control_action(ControlAction::LoadoutManip(LoadoutManip::Use(equip)))
|
|
||||||
},
|
|
||||||
Slot::Inventory(inv) => self.send_msg(ClientGeneral::ControlEvent(
|
|
||||||
ControlEvent::InventoryManip(InventoryManip::Use(inv)),
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn swap_slots(&mut self, a: Slot, b: Slot) {
|
pub fn swap_slots(&mut self, a: Slot, b: Slot) {
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
(Slot::Equip(equip), slot) | (slot, Slot::Equip(equip)) => {
|
(Slot::Equip(equip), slot) | (slot, Slot::Equip(equip)) => self.control_action(
|
||||||
self.control_action(ControlAction::LoadoutManip(LoadoutManip::Swap(equip, slot)))
|
ControlAction::InventoryAction(InventoryAction::Swap(equip, slot)),
|
||||||
},
|
),
|
||||||
(Slot::Inventory(inv1), Slot::Inventory(inv2)) => {
|
(Slot::Inventory(inv1), Slot::Inventory(inv2)) => {
|
||||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryManip(
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryEvent(
|
||||||
InventoryManip::Swap(inv1, inv2),
|
InventoryEvent::Swap(inv1, inv2),
|
||||||
)))
|
)))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -647,10 +640,10 @@ impl Client {
|
|||||||
pub fn drop_slot(&mut self, slot: Slot) {
|
pub fn drop_slot(&mut self, slot: Slot) {
|
||||||
match slot {
|
match slot {
|
||||||
Slot::Equip(equip) => {
|
Slot::Equip(equip) => {
|
||||||
self.control_action(ControlAction::LoadoutManip(LoadoutManip::Drop(equip)))
|
self.control_action(ControlAction::InventoryAction(InventoryAction::Drop(equip)))
|
||||||
},
|
},
|
||||||
Slot::Inventory(inv) => self.send_msg(ClientGeneral::ControlEvent(
|
Slot::Inventory(inv) => self.send_msg(ClientGeneral::ControlEvent(
|
||||||
ControlEvent::InventoryManip(InventoryManip::Drop(inv)),
|
ControlEvent::InventoryEvent(InventoryEvent::Drop(inv)),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,12 +663,12 @@ impl Client {
|
|||||||
|
|
||||||
pub fn split_swap_slots(&mut self, a: comp::slot::Slot, b: comp::slot::Slot) {
|
pub fn split_swap_slots(&mut self, a: comp::slot::Slot, b: comp::slot::Slot) {
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
(Slot::Equip(equip), slot) | (slot, Slot::Equip(equip)) => {
|
(Slot::Equip(equip), slot) | (slot, Slot::Equip(equip)) => self.control_action(
|
||||||
self.control_action(ControlAction::LoadoutManip(LoadoutManip::Swap(equip, slot)))
|
ControlAction::InventoryAction(InventoryAction::Swap(equip, slot)),
|
||||||
},
|
),
|
||||||
(Slot::Inventory(inv1), Slot::Inventory(inv2)) => {
|
(Slot::Inventory(inv1), Slot::Inventory(inv2)) => {
|
||||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryManip(
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryEvent(
|
||||||
InventoryManip::SplitSwap(inv1, inv2),
|
InventoryEvent::SplitSwap(inv1, inv2),
|
||||||
)))
|
)))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -684,10 +677,10 @@ impl Client {
|
|||||||
pub fn split_drop_slot(&mut self, slot: comp::slot::Slot) {
|
pub fn split_drop_slot(&mut self, slot: comp::slot::Slot) {
|
||||||
match slot {
|
match slot {
|
||||||
Slot::Equip(equip) => {
|
Slot::Equip(equip) => {
|
||||||
self.control_action(ControlAction::LoadoutManip(LoadoutManip::Drop(equip)))
|
self.control_action(ControlAction::InventoryAction(InventoryAction::Drop(equip)))
|
||||||
},
|
},
|
||||||
Slot::Inventory(inv) => self.send_msg(ClientGeneral::ControlEvent(
|
Slot::Inventory(inv) => self.send_msg(ClientGeneral::ControlEvent(
|
||||||
ControlEvent::InventoryManip(InventoryManip::SplitDrop(inv)),
|
ControlEvent::InventoryEvent(InventoryEvent::SplitDrop(inv)),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -701,8 +694,8 @@ impl Client {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryManip(
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryEvent(
|
||||||
InventoryManip::Pickup(uid),
|
InventoryEvent::Pickup(uid),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -740,8 +733,8 @@ impl Client {
|
|||||||
|
|
||||||
pub fn craft_recipe(&mut self, recipe: &str) -> bool {
|
pub fn craft_recipe(&mut self, recipe: &str) -> bool {
|
||||||
if self.can_craft_recipe(recipe) {
|
if self.can_craft_recipe(recipe) {
|
||||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryManip(
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryEvent(
|
||||||
InventoryManip::CraftRecipe(recipe.to_string()),
|
InventoryEvent::CraftRecipe(recipe.to_string()),
|
||||||
)));
|
)));
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
@ -1048,8 +1041,8 @@ impl Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn collect_block(&mut self, pos: Vec3<i32>) {
|
pub fn collect_block(&mut self, pos: Vec3<i32>) {
|
||||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryManip(
|
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryEvent(
|
||||||
InventoryManip::Collect(pos),
|
InventoryEvent::Collect(pos),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,10 +18,9 @@ use vek::*;
|
|||||||
pub const DEFAULT_HOLD_DURATION: Duration = Duration::from_millis(200);
|
pub const DEFAULT_HOLD_DURATION: Duration = Duration::from_millis(200);
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum InventoryManip {
|
pub enum InventoryEvent {
|
||||||
Pickup(Uid),
|
Pickup(Uid),
|
||||||
Collect(Vec3<i32>),
|
Collect(Vec3<i32>),
|
||||||
Use(InvSlotId),
|
|
||||||
Swap(InvSlotId, InvSlotId),
|
Swap(InvSlotId, InvSlotId),
|
||||||
SplitSwap(InvSlotId, InvSlotId),
|
SplitSwap(InvSlotId, InvSlotId),
|
||||||
Drop(InvSlotId),
|
Drop(InvSlotId),
|
||||||
@ -30,14 +29,14 @@ pub enum InventoryManip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum LoadoutManip {
|
pub enum InventoryAction {
|
||||||
Use(EquipSlot),
|
|
||||||
Swap(EquipSlot, Slot),
|
Swap(EquipSlot, Slot),
|
||||||
Drop(EquipSlot),
|
Drop(EquipSlot),
|
||||||
|
Use(Slot),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum SlotManip {
|
pub enum InventoryManip {
|
||||||
Pickup(Uid),
|
Pickup(Uid),
|
||||||
Collect(Vec3<i32>),
|
Collect(Vec3<i32>),
|
||||||
Use(Slot),
|
Use(Slot),
|
||||||
@ -48,31 +47,30 @@ pub enum SlotManip {
|
|||||||
CraftRecipe(String),
|
CraftRecipe(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<LoadoutManip> for SlotManip {
|
impl From<InventoryAction> for InventoryManip {
|
||||||
fn from(loadout_manip: LoadoutManip) -> Self {
|
fn from(inv_action: InventoryAction) -> Self {
|
||||||
match loadout_manip {
|
match inv_action {
|
||||||
LoadoutManip::Use(equip) => Self::Use(Slot::Equip(equip)),
|
InventoryAction::Use(slot) => Self::Use(slot),
|
||||||
LoadoutManip::Swap(equip, slot) => Self::Swap(Slot::Equip(equip), slot),
|
InventoryAction::Swap(equip, slot) => Self::Swap(Slot::Equip(equip), slot),
|
||||||
LoadoutManip::Drop(equip) => Self::Drop(Slot::Equip(equip)),
|
InventoryAction::Drop(equip) => Self::Drop(Slot::Equip(equip)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<InventoryManip> for SlotManip {
|
impl From<InventoryEvent> for InventoryManip {
|
||||||
fn from(inv_manip: InventoryManip) -> Self {
|
fn from(inv_event: InventoryEvent) -> Self {
|
||||||
match inv_manip {
|
match inv_event {
|
||||||
InventoryManip::Pickup(pickup) => Self::Pickup(pickup),
|
InventoryEvent::Pickup(pickup) => Self::Pickup(pickup),
|
||||||
InventoryManip::Collect(collect) => Self::Collect(collect),
|
InventoryEvent::Collect(collect) => Self::Collect(collect),
|
||||||
InventoryManip::Use(inv) => Self::Use(Slot::Inventory(inv)),
|
InventoryEvent::Swap(inv1, inv2) => {
|
||||||
InventoryManip::Swap(inv1, inv2) => {
|
|
||||||
Self::Swap(Slot::Inventory(inv1), Slot::Inventory(inv2))
|
Self::Swap(Slot::Inventory(inv1), Slot::Inventory(inv2))
|
||||||
},
|
},
|
||||||
InventoryManip::SplitSwap(inv1, inv2) => {
|
InventoryEvent::SplitSwap(inv1, inv2) => {
|
||||||
Self::SplitSwap(Slot::Inventory(inv1), Slot::Inventory(inv2))
|
Self::SplitSwap(Slot::Inventory(inv1), Slot::Inventory(inv2))
|
||||||
},
|
},
|
||||||
InventoryManip::Drop(inv) => Self::Drop(Slot::Inventory(inv)),
|
InventoryEvent::Drop(inv) => Self::Drop(Slot::Inventory(inv)),
|
||||||
InventoryManip::SplitDrop(inv) => Self::SplitDrop(Slot::Inventory(inv)),
|
InventoryEvent::SplitDrop(inv) => Self::SplitDrop(Slot::Inventory(inv)),
|
||||||
InventoryManip::CraftRecipe(recipe) => Self::CraftRecipe(recipe),
|
InventoryEvent::CraftRecipe(recipe) => Self::CraftRecipe(recipe),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +93,7 @@ pub enum ControlEvent {
|
|||||||
PerformTradeAction(TradeId, TradeAction),
|
PerformTradeAction(TradeId, TradeAction),
|
||||||
Mount(Uid),
|
Mount(Uid),
|
||||||
Unmount,
|
Unmount,
|
||||||
InventoryManip(InventoryManip),
|
InventoryEvent(InventoryEvent),
|
||||||
GroupManip(GroupManip),
|
GroupManip(GroupManip),
|
||||||
RemoveBuff(BuffKind),
|
RemoveBuff(BuffKind),
|
||||||
Respawn,
|
Respawn,
|
||||||
@ -104,7 +102,7 @@ pub enum ControlEvent {
|
|||||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum ControlAction {
|
pub enum ControlAction {
|
||||||
SwapEquippedWeapons,
|
SwapEquippedWeapons,
|
||||||
LoadoutManip(LoadoutManip),
|
InventoryAction(InventoryAction),
|
||||||
Wield,
|
Wield,
|
||||||
GlideWield,
|
GlideWield,
|
||||||
Unwield,
|
Unwield,
|
||||||
|
@ -62,7 +62,7 @@ pub use self::{
|
|||||||
combo::Combo,
|
combo::Combo,
|
||||||
controller::{
|
controller::{
|
||||||
Climb, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip, Input,
|
Climb, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip, Input,
|
||||||
InventoryManip, LoadoutManip, MountState, Mounting, SlotManip,
|
InventoryAction, InventoryEvent, InventoryManip, MountState, Mounting,
|
||||||
},
|
},
|
||||||
energy::{Energy, EnergyChange, EnergySource},
|
energy::{Energy, EnergyChange, EnergySource},
|
||||||
group::Group,
|
group::Group,
|
||||||
|
@ -54,7 +54,7 @@ pub enum ServerEvent {
|
|||||||
entity: EcsEntity,
|
entity: EcsEntity,
|
||||||
cause: comp::HealthSource,
|
cause: comp::HealthSource,
|
||||||
},
|
},
|
||||||
InventoryManip(EcsEntity, comp::SlotManip),
|
InventoryManip(EcsEntity, comp::InventoryManip),
|
||||||
GroupManip(EcsEntity, comp::GroupManip),
|
GroupManip(EcsEntity, comp::GroupManip),
|
||||||
Respawn(EcsEntity),
|
Respawn(EcsEntity),
|
||||||
Shoot {
|
Shoot {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
item::MaterialStatManifest, Beam, Body, CharacterState, Combo, ControlAction, Controller,
|
item::MaterialStatManifest, Beam, Body, CharacterState, Combo, ControlAction, Controller,
|
||||||
ControllerInputs, Energy, Health, Inventory, LoadoutManip, Melee, Ori, PhysicsState, Pos,
|
ControllerInputs, Energy, Health, Inventory, InventoryAction, Melee, Ori, PhysicsState,
|
||||||
StateUpdate, Stats, Vel,
|
Pos, StateUpdate, Stats, Vel,
|
||||||
},
|
},
|
||||||
resources::DeltaTime,
|
resources::DeltaTime,
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
@ -18,7 +18,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_equipped_weapons(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
fn swap_equipped_weapons(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||||
fn manipulate_loadout(&self, data: &JoinData, _loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, _inv_action: InventoryAction) -> 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) }
|
||||||
@ -32,9 +32,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::SwapEquippedWeapons => self.swap_equipped_weapons(data),
|
ControlAction::SwapEquippedWeapons => self.swap_equipped_weapons(data),
|
||||||
ControlAction::LoadoutManip(loadout_manip) => {
|
ControlAction::InventoryAction(inv_action) => self.manipulate_loadout(data, inv_action),
|
||||||
self.manipulate_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, LoadoutManip, StateUpdate},
|
comp::{CharacterState, InventoryAction, 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 manipulate_loadout(&self, data: &JoinData, loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_manipulate_loadout(&data, &mut update, loadout_manip);
|
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{slot::EquipSlot, CharacterState, EnergySource, LoadoutManip, StateUpdate},
|
comp::{slot::EquipSlot, CharacterState, EnergySource, InventoryAction, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,9 +69,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manipulate_loadout(&self, data: &JoinData, loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_manipulate_loadout(&data, &mut update, loadout_manip);
|
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{LoadoutManip, StateUpdate},
|
comp::{InventoryAction, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manipulate_loadout(&self, data: &JoinData, loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_manipulate_loadout(&data, &mut update, loadout_manip);
|
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, LoadoutManip, StateUpdate},
|
comp::{CharacterState, InventoryAction, 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 manipulate_loadout(&self, data: &JoinData, loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_manipulate_loadout(&data, &mut update, loadout_manip);
|
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, LoadoutManip, StateUpdate},
|
comp::{CharacterState, InventoryAction, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,9 +60,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manipulate_loadout(&self, data: &JoinData, loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_manipulate_loadout(&data, &mut update, loadout_manip);
|
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, LoadoutManip, StateUpdate},
|
comp::{CharacterState, InventoryAction, 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 manipulate_loadout(&self, data: &JoinData, loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_manipulate_loadout(&data, &mut update, loadout_manip);
|
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use crate::{
|
|||||||
item::{Hands, ItemKind, Tool, ToolKind},
|
item::{Hands, ItemKind, Tool, ToolKind},
|
||||||
quadruped_low, quadruped_medium, quadruped_small,
|
quadruped_low, quadruped_medium, quadruped_small,
|
||||||
skills::Skill,
|
skills::Skill,
|
||||||
theropod, Body, CharacterAbility, CharacterState, LoadoutManip, StateUpdate,
|
theropod, Body, CharacterAbility, CharacterState, InventoryAction, StateUpdate,
|
||||||
},
|
},
|
||||||
consts::{FRIC_GROUND, GRAVITY},
|
consts::{FRIC_GROUND, GRAVITY},
|
||||||
event::{LocalEvent, ServerEvent},
|
event::{LocalEvent, ServerEvent},
|
||||||
@ -395,12 +395,11 @@ pub fn attempt_swap_equipped_weapons(data: &JoinData, update: &mut StateUpdate)
|
|||||||
pub fn handle_manipulate_loadout(
|
pub fn handle_manipulate_loadout(
|
||||||
data: &JoinData,
|
data: &JoinData,
|
||||||
update: &mut StateUpdate,
|
update: &mut StateUpdate,
|
||||||
loadout_manip: LoadoutManip,
|
inv_action: InventoryAction,
|
||||||
) {
|
) {
|
||||||
update.server_events.push_front(ServerEvent::InventoryManip(
|
update
|
||||||
data.entity,
|
.server_events
|
||||||
loadout_manip.into(),
|
.push_front(ServerEvent::InventoryManip(data.entity, inv_action.into()));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that player can wield the glider and updates `CharacterState` if so
|
/// Checks that player can wield the glider and updates `CharacterState` if so
|
||||||
|
@ -2,7 +2,7 @@ use super::utils::*;
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
slot::{EquipSlot, Slot},
|
slot::{EquipSlot, Slot},
|
||||||
CharacterState, LoadoutManip, StateUpdate,
|
CharacterState, InventoryAction, StateUpdate,
|
||||||
},
|
},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
@ -61,17 +61,17 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manipulate_loadout(&self, data: &JoinData, loadout_manip: LoadoutManip) -> StateUpdate {
|
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
match loadout_manip {
|
match inv_action {
|
||||||
LoadoutManip::Drop(EquipSlot::Mainhand)
|
InventoryAction::Drop(EquipSlot::Mainhand)
|
||||||
| LoadoutManip::Swap(EquipSlot::Mainhand, _)
|
| InventoryAction::Swap(EquipSlot::Mainhand, _)
|
||||||
| LoadoutManip::Swap(_, Slot::Equip(EquipSlot::Mainhand)) => {
|
| InventoryAction::Swap(_, Slot::Equip(EquipSlot::Mainhand)) => {
|
||||||
update.character = CharacterState::Idle;
|
update.character = CharacterState::Idle;
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
handle_manipulate_loadout(&data, &mut update, loadout_manip);
|
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
server_emitter
|
server_emitter
|
||||||
.emit(ServerEvent::ProcessTradeAction(entity, trade_id, action));
|
.emit(ServerEvent::ProcessTradeAction(entity, trade_id, action));
|
||||||
},
|
},
|
||||||
ControlEvent::InventoryManip(manip) => {
|
ControlEvent::InventoryEvent(event) => {
|
||||||
server_emitter.emit(ServerEvent::InventoryManip(entity, manip.into()));
|
server_emitter.emit(ServerEvent::InventoryManip(entity, event.into()));
|
||||||
},
|
},
|
||||||
ControlEvent::GroupManip(manip) => {
|
ControlEvent::GroupManip(manip) => {
|
||||||
server_emitter.emit(ServerEvent::GroupManip(entity, manip))
|
server_emitter.emit(ServerEvent::GroupManip(entity, manip))
|
||||||
|
@ -39,7 +39,7 @@ pub fn snuff_lantern(storage: &mut WriteStorage<comp::LightEmitter>, entity: Ecs
|
|||||||
|
|
||||||
#[allow(clippy::blocks_in_if_conditions)]
|
#[allow(clippy::blocks_in_if_conditions)]
|
||||||
#[allow(clippy::same_item_push)] // TODO: Pending review in #587
|
#[allow(clippy::same_item_push)] // TODO: Pending review in #587
|
||||||
pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::SlotManip) {
|
pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::InventoryManip) {
|
||||||
let state = server.state_mut();
|
let state = server.state_mut();
|
||||||
|
|
||||||
let uid = state
|
let uid = state
|
||||||
@ -76,7 +76,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
};
|
};
|
||||||
|
|
||||||
match manip {
|
match manip {
|
||||||
comp::SlotManip::Pickup(uid) => {
|
comp::InventoryManip::Pickup(uid) => {
|
||||||
let picked_up_item: Option<comp::Item>;
|
let picked_up_item: Option<comp::Item>;
|
||||||
let item_entity = if let (Some((item, item_entity)), Some(mut inv)) = (
|
let item_entity = if let (Some((item, item_entity)), Some(mut inv)) = (
|
||||||
state
|
state
|
||||||
@ -148,8 +148,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
|
|
||||||
state.write_component(entity, event);
|
state.write_component(entity, event);
|
||||||
},
|
},
|
||||||
|
comp::InventoryManip::Collect(pos) => {
|
||||||
comp::SlotManip::Collect(pos) => {
|
|
||||||
let block = state.terrain().get(pos).ok().copied();
|
let block = state.terrain().get(pos).ok().copied();
|
||||||
|
|
||||||
if let Some(block) = block {
|
if let Some(block) = block {
|
||||||
@ -219,8 +218,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
comp::InventoryManip::Use(slot) => {
|
||||||
comp::SlotManip::Use(slot) => {
|
|
||||||
let mut inventories = state.ecs().write_storage::<comp::Inventory>();
|
let mut inventories = state.ecs().write_storage::<comp::Inventory>();
|
||||||
let mut inventory = if let Some(inventory) = inventories.get_mut(entity) {
|
let mut inventory = if let Some(inventory) = inventories.get_mut(entity) {
|
||||||
inventory
|
inventory
|
||||||
@ -423,8 +421,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
state.write_component(entity, comp::InventoryUpdate::new(event));
|
state.write_component(entity, comp::InventoryUpdate::new(event));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
comp::InventoryManip::Swap(a, b) => {
|
||||||
comp::SlotManip::Swap(a, b) => {
|
|
||||||
let ecs = state.ecs();
|
let ecs = state.ecs();
|
||||||
|
|
||||||
if let Some(pos) = ecs.read_storage::<comp::Pos>().get(entity) {
|
if let Some(pos) = ecs.read_storage::<comp::Pos>().get(entity) {
|
||||||
@ -458,8 +455,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Swapped),
|
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Swapped),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
comp::InventoryManip::SplitSwap(slot, target) => {
|
||||||
comp::SlotManip::SplitSwap(slot, target) => {
|
|
||||||
let msm = state.ecs().read_resource::<MaterialStatManifest>();
|
let msm = state.ecs().read_resource::<MaterialStatManifest>();
|
||||||
let mut inventories = state.ecs().write_storage::<comp::Inventory>();
|
let mut inventories = state.ecs().write_storage::<comp::Inventory>();
|
||||||
let mut inventory = if let Some(inventory) = inventories.get_mut(entity) {
|
let mut inventory = if let Some(inventory) = inventories.get_mut(entity) {
|
||||||
@ -507,8 +503,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Swapped),
|
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Swapped),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
comp::InventoryManip::Drop(slot) => {
|
||||||
comp::SlotManip::Drop(slot) => {
|
|
||||||
let item = match slot {
|
let item = match slot {
|
||||||
Slot::Inventory(slot) => state
|
Slot::Inventory(slot) => state
|
||||||
.ecs()
|
.ecs()
|
||||||
@ -540,8 +535,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Dropped),
|
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Dropped),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
comp::InventoryManip::SplitDrop(slot) => {
|
||||||
comp::SlotManip::SplitDrop(slot) => {
|
|
||||||
let msm = state.ecs().read_resource::<MaterialStatManifest>();
|
let msm = state.ecs().read_resource::<MaterialStatManifest>();
|
||||||
let item = match slot {
|
let item = match slot {
|
||||||
Slot::Inventory(slot) => state
|
Slot::Inventory(slot) => state
|
||||||
@ -571,8 +565,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
|
|||||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Dropped),
|
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Dropped),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
comp::InventoryManip::CraftRecipe(recipe) => {
|
||||||
comp::SlotManip::CraftRecipe(recipe) => {
|
|
||||||
if let Some(mut inv) = state
|
if let Some(mut inv) = state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<comp::Inventory>()
|
.write_storage::<comp::Inventory>()
|
||||||
|
Loading…
Reference in New Issue
Block a user