mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
handle overlap and queueing correctly
This commit is contained in:
parent
df7c2ee70a
commit
3a7bb698fc
@ -772,18 +772,26 @@ impl Buffs {
|
|||||||
|
|
||||||
pub fn insert(&mut self, buff: Buff, current_time: Time) -> BuffKey {
|
pub fn insert(&mut self, buff: Buff, current_time: Time) -> BuffKey {
|
||||||
let kind = buff.kind;
|
let kind = buff.kind;
|
||||||
// Try to find another buff with same data, cat_ids and source
|
// Try to find another overlaping non-queueable buff with same data, cat_ids and
|
||||||
let other_key = self.kinds[kind].as_ref().and_then(|(keys, _)| {
|
// source.
|
||||||
keys.iter()
|
let other_key = if kind.queues() {
|
||||||
.find(|key| {
|
None
|
||||||
self.buffs.get(**key).map_or(false, |other_buff| {
|
} else {
|
||||||
other_buff.data == buff.data
|
self.kinds[kind].as_ref().and_then(|(keys, _)| {
|
||||||
&& other_buff.cat_ids == buff.cat_ids
|
keys.iter()
|
||||||
&& other_buff.source == buff.source
|
.find(|key| {
|
||||||
|
self.buffs.get(**key).map_or(false, |other_buff| {
|
||||||
|
other_buff.data == buff.data
|
||||||
|
&& other_buff.cat_ids == buff.cat_ids
|
||||||
|
&& other_buff.source == buff.source
|
||||||
|
&& other_buff
|
||||||
|
.end_time
|
||||||
|
.map_or(true, |end_time| end_time.0 >= buff.start_time.0)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
.copied()
|
||||||
.copied()
|
})
|
||||||
});
|
};
|
||||||
|
|
||||||
// If another buff with the same fields is found, update end_time and effects
|
// If another buff with the same fields is found, update end_time and effects
|
||||||
let key = if let Some((other_buff, key)) =
|
let key = if let Some((other_buff, key)) =
|
||||||
|
Loading…
Reference in New Issue
Block a user