mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix tag removing
This commit is contained in:
parent
b1718cf578
commit
114715908a
@ -47,7 +47,10 @@ impl Behavior {
|
||||
/// Revoke a tag to the Behavior
|
||||
pub fn remove_tag(&mut self, tag: BehaviorTag) {
|
||||
if self.has_tag(&tag) {
|
||||
self.tags.remove(&tag);
|
||||
let tag = self.get_tag(&tag).cloned();
|
||||
if let Some(tag) = tag {
|
||||
self.tags.remove(&tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,10 +62,10 @@ impl Behavior {
|
||||
}
|
||||
|
||||
/// Get a specific tag by variant
|
||||
pub fn get_tag(&self, tag: BehaviorTag) -> Option<&BehaviorTag> {
|
||||
pub fn get_tag(&self, tag: &BehaviorTag) -> Option<&BehaviorTag> {
|
||||
self.tags
|
||||
.iter()
|
||||
.find(|behavior_tag| mem::discriminant(*behavior_tag) == mem::discriminant(&tag))
|
||||
.find(|behavior_tag| mem::discriminant(*behavior_tag) == mem::discriminant(tag))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ impl Index {
|
||||
pub fn colors(&self) -> AssetHandle<Arc<Colors>> { self.colors }
|
||||
|
||||
pub fn get_site_prices(&self, behavior: &Behavior) -> Option<SitePrices> {
|
||||
if let Some(BehaviorTag::CanTrade(site_id)) = behavior.get_tag(BehaviorTag::CanTrade(None))
|
||||
if let Some(BehaviorTag::CanTrade(site_id)) = behavior.get_tag(&BehaviorTag::CanTrade(None))
|
||||
{
|
||||
site_id
|
||||
.map(|i| self.sites.recreate_id(i))
|
||||
|
Loading…
Reference in New Issue
Block a user