wowlab_engine_combat/state/
config.rs1use wowlab_engine_ports::CombatStats;
2
3use super::{AccumulatingImpactProc, CastHookFn, ImpactEffectProc, ImpactProc, ResourceGainProc};
4
5#[derive(Clone, Debug)]
7pub struct BaseStats {
8 pub stats: CombatStats,
9 pub primary_attribute: Option<wowlab_types::game::Attribute>,
10 pub base_regen: f64,
11 pub resource_max: f64,
12 pub resource_start: f64,
13 pub resource_name: String,
14 pub has_pet: bool,
15 pub secondary_resource_name: Option<String>,
16 pub secondary_resource_max: f64,
17 pub resource_type: Option<wowlab_types::combat::ResourceType>,
18 pub secondary_resource_type: Option<wowlab_types::combat::ResourceType>,
19 pub swing_resource_gain_mult: f64,
20}
21
22#[derive(Debug, Default)]
24pub struct ScratchBuffers {
25 pub hooks: Vec<CastHookFn>,
26 pub impacts: Vec<ImpactProc>,
27 pub accumulating_impacts: Vec<AccumulatingImpactProc>,
28 pub impact_effects: Vec<ImpactEffectProc>,
29 pub resource_gains: Vec<ResourceGainProc>,
30}
31
32#[derive(Clone, Copy)]
33pub(crate) enum ScratchDisposition {
34 PreserveSource,
35 PersistChanges,
36}
37
38pub(crate) fn with_scratch<T>(
39 source: Vec<T>,
40 mut scratch: Vec<T>,
41 disposition: ScratchDisposition,
42 use_entries: impl FnOnce(&mut Vec<T>),
43) -> (Vec<T>, Vec<T>)
44where
45 T: Copy,
46{
47 scratch.clear();
48 scratch.extend(source.iter().copied());
49 use_entries(&mut scratch);
50
51 match disposition {
52 ScratchDisposition::PreserveSource => (source, scratch),
53 ScratchDisposition::PersistChanges => (scratch, source),
54 }
55}