feat: implemented extra status effect effectiveness and duration
This commit is contained in:
parent
9b720facf8
commit
39c6714317
3 changed files with 68 additions and 12 deletions
|
|
@ -6,7 +6,13 @@ use proxisim_models::bundle::{
|
|||
},
|
||||
};
|
||||
|
||||
use crate::{Stages, effect::Effects};
|
||||
use crate::{
|
||||
Stages,
|
||||
effect::Effects,
|
||||
player::status_effect::{
|
||||
ExtraStatusEffectEffectiveness, Hardened, Hastened, Sharpened, Strengthened,
|
||||
},
|
||||
};
|
||||
|
||||
fn spawn_permanent_effects(
|
||||
merit_q: Query<(
|
||||
|
|
@ -17,6 +23,7 @@ fn spawn_permanent_effects(
|
|||
Option<&DrugCooldown>,
|
||||
)>,
|
||||
mut effects: Effects,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
for (player, merits, edu, faction, drug_cd) in merit_q.iter() {
|
||||
if merits.brawn > 0 {
|
||||
|
|
@ -211,6 +218,14 @@ fn spawn_permanent_effects(
|
|||
if edu.def2760 {
|
||||
effects.spawn(AdditiveBonus::<Speed>::new("DEF2760", 0.03), player);
|
||||
}
|
||||
if edu.spt2480 {
|
||||
commands.entity(player).insert((
|
||||
ExtraStatusEffectEffectiveness::<1, Strengthened>::new(1.1),
|
||||
ExtraStatusEffectEffectiveness::<1, Sharpened>::new(1.1),
|
||||
ExtraStatusEffectEffectiveness::<1, Hardened>::new(1.1),
|
||||
ExtraStatusEffectEffectiveness::<1, Hastened>::new(1.1),
|
||||
));
|
||||
}
|
||||
if edu.spt2490 {
|
||||
effects.spawn(AdditiveBonus::<Speed>::new("SPT2490", 0.02), player);
|
||||
effects.spawn(AdditiveBonus::<Strength>::new("SPT2490", 0.02), player);
|
||||
|
|
|
|||
|
|
@ -562,7 +562,6 @@ fn use_damaging_weapon(
|
|||
_ => 0.0,
|
||||
})
|
||||
.unwrap_or_default();
|
||||
// TODO: special ammo
|
||||
|
||||
let mut dmg = dmg_intrinsic
|
||||
* w_dmg.0
|
||||
|
|
|
|||
|
|
@ -162,16 +162,54 @@ where
|
|||
M: AdditiveStatusEffectMarker<N>,
|
||||
{
|
||||
marker: PhantomData<M>,
|
||||
extra_effectiveness: f32,
|
||||
extra_duration: f32,
|
||||
}
|
||||
|
||||
impl<const N: usize, M: AdditiveStatusEffectMarker<N>> Default for AdditiveStatusEffect<N, M> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
marker: PhantomData,
|
||||
extra_effectiveness: 0.0,
|
||||
extra_duration: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct ExtraStatusEffectEffectiveness<const N: usize, M>
|
||||
where
|
||||
M: AdditiveStatusEffectMarker<N>,
|
||||
{
|
||||
marker: PhantomData<M>,
|
||||
pub factor: f32,
|
||||
}
|
||||
|
||||
impl<const N: usize, M> ExtraStatusEffectEffectiveness<N, M>
|
||||
where
|
||||
M: AdditiveStatusEffectMarker<N>,
|
||||
{
|
||||
pub fn new(factor: f32) -> Self {
|
||||
Self {
|
||||
marker: PhantomData,
|
||||
factor,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct ExtraStatusEffectDuration<const N: usize, M>
|
||||
where
|
||||
M: AdditiveStatusEffectMarker<N>,
|
||||
{
|
||||
marker: PhantomData<M>,
|
||||
pub factor: f32,
|
||||
}
|
||||
|
||||
impl<const N: usize, M> ExtraStatusEffectDuration<N, M>
|
||||
where
|
||||
M: AdditiveStatusEffectMarker<N>,
|
||||
{
|
||||
pub fn new(factor: f32) -> Self {
|
||||
Self {
|
||||
marker: PhantomData,
|
||||
factor,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -383,30 +421,34 @@ impl DamageOverTimeMarker for Bleed {
|
|||
|
||||
fn apply_additive_status_effect<const N: usize, M: AdditiveStatusEffectMarker<N>>(
|
||||
In(entities): In<Vec<Entity>>,
|
||||
effect_q: Query<(Entity, &ChildOf, &AdditiveStatusEffect<N, M>)>,
|
||||
mut parent_q: Query<Option<&mut StatusEffectStack<M>>>,
|
||||
effect_q: Query<(Entity, &ChildOf)>,
|
||||
mut parent_q: Query<(
|
||||
Option<&mut StatusEffectStack<M>>,
|
||||
Option<&ExtraStatusEffectDuration<N, M>>,
|
||||
Option<&ExtraStatusEffectEffectiveness<N, M>>,
|
||||
)>,
|
||||
mut commands: Commands,
|
||||
mut effects: Effects,
|
||||
mut logger: Logger,
|
||||
) {
|
||||
for (entity, player, effect) in effect_q.iter_many(entities) {
|
||||
for (entity, player) in effect_q.iter_many(entities) {
|
||||
log!(logger, "apply_status_effect", {
|
||||
recipient: player.parent(),
|
||||
effect: std::any::type_name::<M>(),
|
||||
});
|
||||
|
||||
let stack = parent_q.get_mut(player.parent()).unwrap();
|
||||
let (stack, extra_duration, extra_effect) = parent_q.get_mut(player.parent()).unwrap();
|
||||
|
||||
let new_effects = <M::AffectedStats as Stats<N>>::spawn_additive_effects(
|
||||
&mut effects,
|
||||
player.parent(),
|
||||
M::factor() * (1.0 + effect.extra_effectiveness),
|
||||
M::factor() * extra_effect.map_or(1.0, |e| e.factor),
|
||||
std::any::type_name::<M>(),
|
||||
);
|
||||
|
||||
commands.entity(entity).insert((
|
||||
LinkedComponents(new_effects),
|
||||
TimeLimitedEffect(M::duration() * (1.0 + effect.extra_duration)),
|
||||
TimeLimitedEffect(M::duration() * extra_duration.map_or(1.0, |e| e.factor)),
|
||||
));
|
||||
|
||||
if let Some(mut stack) = stack {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue