fixed first round effect and migrated logging
This commit is contained in:
parent
b45d04b872
commit
e7d6b74aab
10 changed files with 539 additions and 222 deletions
22
src/lib.rs
22
src/lib.rs
|
|
@ -149,7 +149,7 @@ impl Simulation {
|
|||
|
||||
pub fn truncate_log(&mut self) {
|
||||
let mut log = self.0.world.resource_mut::<Log>();
|
||||
log.entries.clear();
|
||||
log.clear();
|
||||
}
|
||||
|
||||
pub fn set_metrics(&mut self, recording: bool) {
|
||||
|
|
@ -158,6 +158,16 @@ impl Simulation {
|
|||
}
|
||||
|
||||
pub fn consume_metrics(&mut self) -> (Vec<dto::Counter>, Vec<dto::Histogram>) {
|
||||
let entities = self.0.world.entities().len();
|
||||
let components = self.0.world.components().len();
|
||||
self.0
|
||||
.world
|
||||
.resource::<metrics::Metrics>()
|
||||
.increment_counter(Entity::from_raw(0), "entities", entities.into());
|
||||
self.0
|
||||
.world
|
||||
.resource::<metrics::Metrics>()
|
||||
.increment_counter(Entity::from_raw(0), "components", components as u64);
|
||||
metrics::consume_metrics(&self.0.world)
|
||||
}
|
||||
|
||||
|
|
@ -352,7 +362,7 @@ mod tests {
|
|||
clip_size: 25,
|
||||
rate_of_fire: [3, 5],
|
||||
},
|
||||
mods: Vec::default(),
|
||||
mods: vec![WeaponMod::HairTrigger],
|
||||
bonuses: vec![WeaponBonusInfo {
|
||||
bonus: WeaponBonus::Expose,
|
||||
value: 9.0,
|
||||
|
|
@ -431,17 +441,15 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn init_simulator() {
|
||||
let mut sim = Simulation::new(attacker(), defender());
|
||||
sim.run_once();
|
||||
Simulation::new(attacker(), defender());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn metrics() {
|
||||
let mut sim = Simulation::new(attacker(), defender());
|
||||
sim.set_metrics(true);
|
||||
for _ in 0..20 {
|
||||
sim.run_once();
|
||||
}
|
||||
sim.run_once();
|
||||
sim.consume_metrics();
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue