Skip to content

Commit 7a8d8b3

Browse files
committed
Use block comment for Scope
1 parent 093f43d commit 7a8d8b3

1 file changed

Lines changed: 77 additions & 75 deletions

File tree

src/server/visibility.rs

Lines changed: 77 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -257,81 +257,83 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
257257
*/
258258
type ClientComponent: Component<Mutability = Immutable>;
259259

260-
/// Defines what data is affected when the filter denies visibility.
261-
///
262-
/// - To hide the entire entity, this type must be [`Entity`].
263-
/// - To hide a single component on the entity, this type must be [`SingleComponent`].
264-
/// - To hide more than one component on the entity, this type must be a tuple of those [`Component`]s.
265-
///
266-
/// # Examples
267-
///
268-
/// Hide the entire entity:
269-
///
270-
/// ```
271-
/// # use bevy::prelude::*;
272-
/// # use bevy_replicon::prelude::*;
273-
/// #[derive(Component, PartialEq)]
274-
/// #[component(immutable)]
275-
/// struct Team(u8);
276-
///
277-
/// impl VisibilityFilter for Team {
278-
/// type ClientComponent = Self;
279-
/// type Scope = Entity;
280-
///
281-
/// fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
282-
/// component.is_some_and(|c| self == c)
283-
/// }
284-
/// }
285-
/// ```
286-
///
287-
/// Hide only a single component:
288-
///
289-
/// ```
290-
/// # use bevy::prelude::*;
291-
/// # use bevy_replicon::prelude::*;
292-
/// #[derive(Component, PartialEq)]
293-
/// #[component(immutable)]
294-
/// struct Team(u8);
295-
///
296-
/// impl VisibilityFilter for Team {
297-
/// type ClientComponent = Self;
298-
/// type Scope = SingleComponent<Health>;
299-
///
300-
/// fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
301-
/// component.is_some_and(|c| self == c)
302-
/// }
303-
/// }
304-
///
305-
/// #[derive(Component)]
306-
/// struct Health(u8);
307-
/// ```
308-
///
309-
/// Hide multiple components:
310-
///
311-
/// ```
312-
/// # use bevy::prelude::*;
313-
/// # use bevy_replicon::prelude::*;
314-
/// #[derive(Component, PartialEq)]
315-
/// #[component(immutable)]
316-
/// struct Team(u8);
317-
///
318-
/// impl VisibilityFilter for Team {
319-
/// type ClientComponent = Self;
320-
/// type Scope = (Health, Stats);
321-
///
322-
/// fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
323-
/// component.is_some_and(|c| self == c)
324-
/// }
325-
/// }
326-
///
327-
/// #[derive(Component)]
328-
/// struct Health(u8);
329-
///
330-
/// #[derive(Component)]
331-
/// struct Stats {
332-
/// // ...
333-
/// }
334-
/// ```
260+
/**
261+
Defines what data is affected when the filter denies visibility.
262+
263+
- To hide the entire entity, this type must be [`Entity`].
264+
- To hide a single component on the entity, this type must be [`SingleComponent`].
265+
- To hide more than one component on the entity, this type must be a tuple of those [`Component`]s.
266+
267+
# Examples
268+
269+
Hide the entire entity:
270+
271+
```
272+
# use bevy::prelude::*;
273+
# use bevy_replicon::prelude::*;
274+
#[derive(Component, PartialEq)]
275+
#[component(immutable)]
276+
struct Team(u8);
277+
278+
impl VisibilityFilter for Team {
279+
type ClientComponent = Self;
280+
type Scope = Entity;
281+
282+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
283+
component.is_some_and(|c| self == c)
284+
}
285+
}
286+
```
287+
288+
Hide only a single component:
289+
290+
```
291+
# use bevy::prelude::*;
292+
# use bevy_replicon::prelude::*;
293+
#[derive(Component, PartialEq)]
294+
#[component(immutable)]
295+
struct Team(u8);
296+
297+
impl VisibilityFilter for Team {
298+
type ClientComponent = Self;
299+
type Scope = SingleComponent<Health>;
300+
301+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
302+
component.is_some_and(|c| self == c)
303+
}
304+
}
305+
306+
#[derive(Component)]
307+
struct Health(u8);
308+
```
309+
310+
Hide multiple components:
311+
312+
```
313+
# use bevy::prelude::*;
314+
# use bevy_replicon::prelude::*;
315+
#[derive(Component, PartialEq)]
316+
#[component(immutable)]
317+
struct Team(u8);
318+
319+
impl VisibilityFilter for Team {
320+
type ClientComponent = Self;
321+
type Scope = (Health, Stats);
322+
323+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
324+
component.is_some_and(|c| self == c)
325+
}
326+
}
327+
328+
#[derive(Component)]
329+
struct Health(u8);
330+
331+
#[derive(Component)]
332+
struct Stats {
333+
// ...
334+
}
335+
```
336+
*/
335337
type Scope: FilterScope;
336338

337339
/**

0 commit comments

Comments
 (0)