|
|
@ -268,36 +268,36 @@ pub struct InventoryItem { |
|
|
|
}
|
|
|
|
|
|
|
|
impl InventoryItem {
|
|
|
|
pub async fn with_entity_id<F, Fut, T>(&self, mut param: T, mut func: F) -> T
|
|
|
|
pub async fn with_entity_id<F, Fut, T>(&self, mut param: T, mut func: F) -> Result<T, ItemStateError>
|
|
|
|
where
|
|
|
|
F: FnMut(T, ItemEntityId) -> Fut,
|
|
|
|
Fut: Future<Output=T>,
|
|
|
|
Fut: Future<Output=Result<T, ItemStateError>>,
|
|
|
|
{
|
|
|
|
match &self.item {
|
|
|
|
InventoryItemDetail::Individual(individual_item) => {
|
|
|
|
param = func(param, individual_item.entity_id).await;
|
|
|
|
param = func(param, individual_item.entity_id).await?;
|
|
|
|
},
|
|
|
|
InventoryItemDetail::Stacked(stacked_item) => {
|
|
|
|
for entity_id in &stacked_item.entity_ids {
|
|
|
|
param = func(param, *entity_id).await;
|
|
|
|
param = func(param, *entity_id).await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
param
|
|
|
|
Ok(param)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn with_mag<F, Fut, T>(&self, mut param: T, mut func: F) -> T
|
|
|
|
pub async fn with_mag<F, Fut, T>(&self, mut param: T, mut func: F) -> Result<T, ItemStateError>
|
|
|
|
where
|
|
|
|
F: FnMut(T, ItemEntityId, Mag) -> Fut,
|
|
|
|
Fut: Future<Output=T>,
|
|
|
|
Fut: Future<Output=Result<T, ItemStateError>>,
|
|
|
|
{
|
|
|
|
if let InventoryItemDetail::Individual(individual_item) = &self.item {
|
|
|
|
if let ItemDetail::Mag(mag) = &individual_item.item {
|
|
|
|
param = func(param, individual_item.entity_id, mag.clone()).await;
|
|
|
|
param = func(param, individual_item.entity_id, mag.clone()).await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
param
|
|
|
|
Ok(param)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
@ -344,23 +344,22 @@ pub struct BankItem { |
|
|
|
}
|
|
|
|
|
|
|
|
impl BankItem {
|
|
|
|
pub async fn with_entity_id<F, Fut, T>(&self, mut param: T, mut func: F) -> T
|
|
|
|
pub async fn with_entity_id<F, Fut, T>(&self, mut param: T, mut func: F) -> Result<T, ItemStateError>
|
|
|
|
where
|
|
|
|
F: FnMut(T, ItemEntityId) -> Fut,
|
|
|
|
Fut: Future<Output=T>,
|
|
|
|
Fut: Future<Output=Result<T, ItemStateError>>,
|
|
|
|
{
|
|
|
|
match &self.item {
|
|
|
|
BankItemDetail::Individual(individual_item) => {
|
|
|
|
param = func(param, individual_item.entity_id).await;
|
|
|
|
param = func(param, individual_item.entity_id).await?;
|
|
|
|
},
|
|
|
|
BankItemDetail::Stacked(stacked_item) => {
|
|
|
|
for entity_id in &stacked_item.entity_ids {
|
|
|
|
param = func(param, *entity_id).await;
|
|
|
|
param = func(param, *entity_id).await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
param
|
|
|
|
Ok(param)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
@ -391,37 +390,37 @@ pub struct FloorItem { |
|
|
|
}
|
|
|
|
|
|
|
|
impl FloorItem {
|
|
|
|
pub async fn with_entity_id<F, Fut, T>(&self, mut param: T, mut func: F) -> T
|
|
|
|
pub async fn with_entity_id<F, Fut, T>(&self, mut param: T, mut func: F) -> Result<T, ItemStateError>
|
|
|
|
where
|
|
|
|
F: FnMut(T, ItemEntityId) -> Fut,
|
|
|
|
Fut: Future<Output=T>,
|
|
|
|
Fut: Future<Output=Result<T, ItemStateError>>,
|
|
|
|
{
|
|
|
|
match &self.item {
|
|
|
|
FloorItemDetail::Individual(individual_item) => {
|
|
|
|
param = func(param, individual_item.entity_id).await;
|
|
|
|
param = func(param, individual_item.entity_id).await?;
|
|
|
|
},
|
|
|
|
FloorItemDetail::Stacked(stacked_item) => {
|
|
|
|
for entity_id in &stacked_item.entity_ids {
|
|
|
|
param = func(param, *entity_id).await;
|
|
|
|
param = func(param, *entity_id).await?;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
FloorItemDetail::Meseta(_meseta) => {},
|
|
|
|
}
|
|
|
|
|
|
|
|
param
|
|
|
|
Ok(param)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn with_mag<F, Fut, T>(&self, mut param: T, mut func: F) -> T
|
|
|
|
pub async fn with_mag<F, Fut, T>(&self, mut param: T, mut func: F) -> Result<T, ItemStateError>
|
|
|
|
where
|
|
|
|
F: FnMut(T, ItemEntityId, Mag) -> Fut,
|
|
|
|
Fut: Future<Output=T>,
|
|
|
|
Fut: Future<Output=Result<T, ItemStateError>>,
|
|
|
|
{
|
|
|
|
if let FloorItemDetail::Individual(individual_item) = &self.item {
|
|
|
|
if let ItemDetail::Mag(mag) = &individual_item.item {
|
|
|
|
param = func(param, individual_item.entity_id, mag.clone()).await;
|
|
|
|
param = func(param, individual_item.entity_id, mag.clone()).await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
param
|
|
|
|
Ok(param)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_client_bytes(&self) -> [u8; 16] {
|
|
|
|