Skip to content

Commit ccb9693

Browse files
committed
Rename client_component into just component
It's obvious from the type
1 parent 6da2c3e commit ccb9693

7 files changed

Lines changed: 48 additions & 100 deletions

File tree

example_backend/examples/authoritative_rts.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,8 @@ impl VisibilityFilter for Team {
750750
type ClientComponent = Self;
751751
type Scope = SingleComponent<Command>;
752752

753-
fn is_visible(
754-
&self,
755-
_client: Entity,
756-
client_component: Option<&Self::ClientComponent>,
757-
) -> bool {
758-
client_component.is_some_and(|c| self == c)
753+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
754+
component.is_some_and(|c| self == c)
759755
}
760756
}
761757

src/server/visibility.rs

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pub trait AppVisibilityExt {
8080
type ClientComponent = Self;
8181
type Scope = Entity;
8282
83-
fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
84-
client_component.is_some_and(|c| self == c)
83+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
84+
component.is_some_and(|c| self == c)
8585
}
8686
}
8787
```
@@ -226,9 +226,9 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
226226
type ClientComponent = Moderator;
227227
type Scope = Entity;
228228
229-
fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
229+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
230230
// Only moderators can see entities with sensitive information.
231-
client_component.is_some()
231+
component.is_some()
232232
}
233233
}
234234
```
@@ -246,9 +246,9 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
246246
type ClientComponent = Self;
247247
type Scope = Entity;
248248
249-
fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
249+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
250250
// Visible only if the client also has `SpectatorOnly`.
251-
client_component.is_some()
251+
component.is_some()
252252
}
253253
}
254254
```
@@ -276,8 +276,8 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
276276
/// type ClientComponent = Self;
277277
/// type Scope = Entity;
278278
///
279-
/// fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
280-
/// client_component.is_some_and(|c| self == c)
279+
/// fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
280+
/// component.is_some_and(|c| self == c)
281281
/// }
282282
/// }
283283
/// ```
@@ -295,8 +295,8 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
295295
/// type ClientComponent = Self;
296296
/// type Scope = SingleComponent<Health>;
297297
///
298-
/// fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
299-
/// client_component.is_some_and(|c| self == c)
298+
/// fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
299+
/// component.is_some_and(|c| self == c)
300300
/// }
301301
/// }
302302
///
@@ -317,8 +317,8 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
317317
/// type ClientComponent = Self;
318318
/// type Scope = (Health, Stats);
319319
///
320-
/// fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
321-
/// client_component.is_some_and(|c| self == c)
320+
/// fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
321+
/// component.is_some_and(|c| self == c)
322322
/// }
323323
/// }
324324
///
@@ -352,8 +352,8 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
352352
type ClientComponent = Self;
353353
type Scope = Entity;
354354
355-
fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
356-
client_component.is_some()
355+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
356+
component.is_some()
357357
}
358358
}
359359
```
@@ -375,9 +375,9 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
375375
type ClientComponent = Unit;
376376
type Scope = Entity;
377377
378-
fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
378+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
379379
// Blind clients cannot see units.
380-
client_component.is_none()
380+
component.is_none()
381381
}
382382
}
383383
```
@@ -395,9 +395,9 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
395395
type ClientComponent = Self;
396396
type Scope = Entity;
397397
398-
fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
398+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
399399
// Visible if the client belongs to the same team.
400-
client_component.is_some_and(|c| self == c)
400+
component.is_some_and(|c| self == c)
401401
}
402402
}
403403
```
@@ -424,8 +424,8 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
424424
type ClientComponent = Self;
425425
type Scope = Entity;
426426
427-
fn is_visible(&self, _client: Entity, client_component: Option<&Self::ClientComponent>) -> bool {
428-
client_component.is_some_and(|&c| self.contains(c))
427+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
428+
component.is_some_and(|&c| self.contains(c))
429429
}
430430
}
431431
```
@@ -443,13 +443,13 @@ pub trait VisibilityFilter: Component<Mutability = Immutable> {
443443
type ClientComponent = AuthorizedClient; // All clients authorized for replication have this component.
444444
type Scope = Entity;
445445
446-
fn is_visible(&self, client: Entity, _client_component: Option<&Self::ClientComponent>) -> bool {
446+
fn is_visible(&self, client: Entity, _component: Option<&Self::ClientComponent>) -> bool {
447447
self.0 == client
448448
}
449449
}
450450
```
451451
*/
452-
fn is_visible(&self, client: Entity, client_component: Option<&Self::ClientComponent>) -> bool;
452+
fn is_visible(&self, client: Entity, component: Option<&Self::ClientComponent>) -> bool;
453453
}
454454

455455
/// Associates the type with a visibility scope.
@@ -661,12 +661,8 @@ mod tests {
661661
type ClientComponent = Self;
662662
type Scope = Entity;
663663

664-
fn is_visible(
665-
&self,
666-
_client: Entity,
667-
client_component: Option<&Self::ClientComponent>,
668-
) -> bool {
669-
client_component.is_some()
664+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
665+
component.is_some()
670666
}
671667
}
672668

@@ -678,12 +674,8 @@ mod tests {
678674
type ClientComponent = ClientFilter;
679675
type Scope = Entity;
680676

681-
fn is_visible(
682-
&self,
683-
_client: Entity,
684-
client_component: Option<&Self::ClientComponent>,
685-
) -> bool {
686-
client_component.is_some()
677+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
678+
component.is_some()
687679
}
688680
}
689681

src/server/visibility/registry.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,8 @@ mod tests {
223223
type ClientComponent = Self;
224224
type Scope = Entity;
225225

226-
fn is_visible(
227-
&self,
228-
_client: Entity,
229-
client_component: Option<&Self::ClientComponent>,
230-
) -> bool {
231-
client_component.is_some()
226+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
227+
component.is_some()
232228
}
233229
}
234230

@@ -240,12 +236,8 @@ mod tests {
240236
type ClientComponent = Self;
241237
type Scope = SingleComponent<A>;
242238

243-
fn is_visible(
244-
&self,
245-
_client: Entity,
246-
client_component: Option<&Self::ClientComponent>,
247-
) -> bool {
248-
client_component.is_some()
239+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
240+
component.is_some()
249241
}
250242
}
251243

@@ -257,12 +249,8 @@ mod tests {
257249
type ClientComponent = Self;
258250
type Scope = (A, B);
259251

260-
fn is_visible(
261-
&self,
262-
_client: Entity,
263-
client_component: Option<&Self::ClientComponent>,
264-
) -> bool {
265-
client_component.is_some()
252+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
253+
component.is_some()
266254
}
267255
}
268256

tests/despawn.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,8 @@ impl VisibilityFilter for EntityVisibility {
328328
type ClientComponent = Self;
329329
type Scope = Entity;
330330

331-
fn is_visible(
332-
&self,
333-
_client: Entity,
334-
client_component: Option<&Self::ClientComponent>,
335-
) -> bool {
336-
client_component.is_some()
331+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
332+
component.is_some()
337333
}
338334
}
339335

@@ -345,11 +341,7 @@ impl VisibilityFilter for ComponentVisibility {
345341
type ClientComponent = Self;
346342
type Scope = SingleComponent<TestComponent>;
347343

348-
fn is_visible(
349-
&self,
350-
_client: Entity,
351-
client_component: Option<&Self::ClientComponent>,
352-
) -> bool {
353-
client_component.is_some()
344+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
345+
component.is_some()
354346
}
355347
}

tests/insertion.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,8 @@ impl VisibilityFilter for EntityVisibility {
802802
type ClientComponent = Self;
803803
type Scope = Entity;
804804

805-
fn is_visible(
806-
&self,
807-
_client: Entity,
808-
client_component: Option<&Self::ClientComponent>,
809-
) -> bool {
810-
client_component.is_some()
805+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
806+
component.is_some()
811807
}
812808
}
813809

@@ -819,12 +815,8 @@ impl VisibilityFilter for ComponentVisibility {
819815
type ClientComponent = Self;
820816
type Scope = SingleComponent<A>;
821817

822-
fn is_visible(
823-
&self,
824-
_client: Entity,
825-
client_component: Option<&Self::ClientComponent>,
826-
) -> bool {
827-
client_component.is_some()
818+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
819+
component.is_some()
828820
}
829821
}
830822

tests/removal.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -640,12 +640,8 @@ impl VisibilityFilter for EntityVisibility {
640640
type ClientComponent = Self;
641641
type Scope = Entity;
642642

643-
fn is_visible(
644-
&self,
645-
_client: Entity,
646-
client_component: Option<&Self::ClientComponent>,
647-
) -> bool {
648-
client_component.is_some()
643+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
644+
component.is_some()
649645
}
650646
}
651647

@@ -657,12 +653,8 @@ impl VisibilityFilter for ComponentVisibility {
657653
type ClientComponent = Self;
658654
type Scope = SingleComponent<A>;
659655

660-
fn is_visible(
661-
&self,
662-
_client: Entity,
663-
client_component: Option<&Self::ClientComponent>,
664-
) -> bool {
665-
client_component.is_some()
656+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
657+
component.is_some()
666658
}
667659
}
668660

tests/spawn.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,11 +583,7 @@ impl VisibilityFilter for EntityVisibility {
583583
type ClientComponent = Self;
584584
type Scope = Entity;
585585

586-
fn is_visible(
587-
&self,
588-
_client: Entity,
589-
client_component: Option<&Self::ClientComponent>,
590-
) -> bool {
591-
client_component.is_some()
586+
fn is_visible(&self, _client: Entity, component: Option<&Self::ClientComponent>) -> bool {
587+
component.is_some()
592588
}
593589
}

0 commit comments

Comments
 (0)