1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use super::*;
use crate::prelude::*;
use crate::sys;
impl World {
/// Constructs a `Alert` from an existing entity.
///
/// This function upcasts the given `entity` to a `Alert`, assuming the entity represents a alert.
/// The purpose is to facilitate the interaction with entities that are specifically alerts within the ECS.
///
/// # Arguments
/// * `entity` - An `EntityView` that represents a alert within the world.
pub fn alert_from<'a>(&'a self, entity: EntityView<'a>) -> Alert<'a> {
Alert::new_from_existing(entity)
}
/// Creates a new `AlertBuilder` instance for constructing alerts.
///
/// This function initializes a `AlertBuilder` which is used to create alerts that match specific components.
/// It is a generic method that works with any component types that implement the `QueryTuple` trait.
///
/// # Type Parameters
/// - `Components`: The components to match on. Must implement the `QueryTuple` trait.
///
/// # See also
///
/// * [`World::alert_named()`]
pub fn alert<Components>(&self) -> AlertBuilder<'_, Components>
where
Components: QueryTuple,
{
AlertBuilder::<Components>::new(self)
}
/// Creates a new named `AlertBuilder` instance.
///
/// Similar to `alert_builder`, but allows naming the alert for easier identification and debugging.
/// The name does not affect the alert's behavior.
///
/// # Arguments
/// * `name` - A string slice representing the name of the alert.
///
/// # Type Parameters
/// - `Components`: The components to match on. Must implement the `QueryTuple` trait.
///
/// # See also
///
/// * [`World::alert()`]
pub fn alert_named<'a, Components>(&'a self, name: &str) -> AlertBuilder<'a, Components>
where
Components: QueryTuple,
{
AlertBuilder::<Components>::new_named(self, name)
}
/// Creates a `AlertBuilder` from a alert description.
///
/// This function allows creating a alert based on a predefined alert description,
/// facilitating more dynamic or configuration-driven alert creation.
///
/// # Arguments
/// * `desc` - A alert description that outlines the parameters for the alert builder.
///
/// # Type Parameters
/// - `Components`: The components to match on. Must implement the `QueryTuple` trait.
pub fn alert_builder_from_desc<Components>(
&self,
desc: sys::ecs_alert_desc_t,
) -> AlertBuilder<'_, Components>
where
Components: QueryTuple,
{
AlertBuilder::<Components>::new_from_desc(self, desc)
}
}