remove_previous -> enforced_limit

This commit is contained in:
maxicarlos08 2023-11-02 16:53:22 +01:00
parent 601056ecbd
commit 17094ad569
No known key found for this signature in database
2 changed files with 26 additions and 22 deletions

View File

@ -956,7 +956,7 @@ pub enum CharacterAbility {
buff_duration: Option<Secs>,
energy_cost: f32,
#[serde(default = "default_true")]
remove_previous: bool,
enforced_limit: bool,
#[serde(default)]
combo_cost: u32,
combo_scaling: Option<ScalingKind>,
@ -1606,7 +1606,7 @@ impl CharacterAbility {
ref mut buff_strength,
buff_duration: _,
ref mut energy_cost,
remove_previous: _,
enforced_limit: _,
combo_cost: _,
combo_scaling: _,
meta: _,
@ -2837,7 +2837,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
energy_cost: _,
combo_cost,
combo_scaling,
remove_previous,
enforced_limit,
meta: _,
} => CharacterState::SelfBuff(self_buff::Data {
static_data: self_buff::StaticData {
@ -2850,7 +2850,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
combo_cost: *combo_cost,
combo_scaling: *combo_scaling,
combo_on_use: data.combo.map_or(0, |c| c.counter()),
remove_previous: *remove_previous,
enforced_limit: *enforced_limit,
ability_info,
},
timer: Duration::default(),

View File

@ -38,7 +38,7 @@ pub struct StaticData {
pub combo_on_use: u32,
/// Controls whether `SelfBuff`s that were previously applied should be
/// removed
pub remove_previous: bool,
pub enforced_limit: bool,
/// What key is used to press ability
pub ability_info: AbilityInfo,
}
@ -81,8 +81,28 @@ impl CharacterBehavior for Data {
change: -(combo_consumption as i32),
});
let scaling_factor = self.static_data.combo_scaling.map_or(1.0, |cs| {
cs.factor(
self.static_data.combo_on_use as f32,
self.static_data.combo_cost as f32,
)
});
let mut buff_cat_ids = if self
.static_data
.ability_info
.ability
.map_or(false, |a| a.ability.is_from_tool())
{
vec![BuffCategory::RemoveOnLoadoutChange]
} else {
Vec::new()
};
// Remove previous selfbuffs if we should
if self.static_data.remove_previous {
if self.static_data.enforced_limit {
buff_cat_ids.push(BuffCategory::SelfBuff);
output_events.emit_server(ServerEvent::Buff {
entity: data.entity,
buff_change: BuffChange::RemoveByCategory {
@ -93,22 +113,6 @@ impl CharacterBehavior for Data {
});
}
let scaling_factor = self.static_data.combo_scaling.map_or(1.0, |cs| {
cs.factor(
self.static_data.combo_on_use as f32,
self.static_data.combo_cost as f32,
)
});
let buff_cat_ids = if self
.static_data
.ability_info
.ability
.map_or(false, |a| a.ability.is_from_tool())
{
vec![BuffCategory::RemoveOnLoadoutChange, BuffCategory::SelfBuff]
} else {
vec![BuffCategory::SelfBuff]
};
// Creates buff
let buff = Buff::new(
self.static_data.buff_kind,