jagua_rs/collision_detection/hazards/
filter.rs1use crate::collision_detection::hazards::HazardEntity;
2
3pub trait HazardFilter {
6 fn is_irrelevant(&self, entity: &HazardEntity) -> bool;
7}
8
9#[derive(Clone, Debug)]
11pub struct NoHazardFilter;
12
13#[derive(Clone, Debug)]
15pub struct ContainerHazardFilter;
16
17#[derive(Clone, Debug)]
19pub struct QZHazardFilter(pub usize);
20
21#[derive(Clone, Debug)]
23pub struct EntityHazardFilter(pub Vec<HazardEntity>);
24
25impl HazardFilter for NoHazardFilter {
26 fn is_irrelevant(&self, _entity: &HazardEntity) -> bool {
27 false
28 }
29}
30
31impl HazardFilter for ContainerHazardFilter {
32 fn is_irrelevant(&self, entity: &HazardEntity) -> bool {
33 match entity {
34 HazardEntity::PlacedItem { .. } => false,
35 HazardEntity::Exterior => true,
36 HazardEntity::Hole { .. } => true,
37 HazardEntity::InferiorQualityZone { .. } => true,
38 }
39 }
40}
41
42impl HazardFilter for EntityHazardFilter {
43 fn is_irrelevant(&self, entity: &HazardEntity) -> bool {
44 self.0.contains(entity)
45 }
46}
47
48impl HazardFilter for QZHazardFilter {
49 fn is_irrelevant(&self, entity: &HazardEntity) -> bool {
50 match entity {
51 HazardEntity::InferiorQualityZone { quality, .. } => *quality >= self.0,
52 _ => false,
53 }
54 }
55}
56
57impl HazardFilter for HazardEntity {
59 fn is_irrelevant(&self, haz: &HazardEntity) -> bool {
60 self == haz
61 }
62}