From 1af4ddd9c9c7d34cb04d283b51a555afdb585683 Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Wed, 6 Sep 2023 18:26:19 +0300 Subject: [PATCH] Rename `ReflectEventComponent` into `ReflectedValue` in tests --- tests/client_event.rs | 10 +++++----- tests/common/mod.rs | 20 +++++++++----------- tests/server_event.rs | 10 +++++----- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/tests/client_event.rs b/tests/client_event.rs index dac494be..4823b8a4 100644 --- a/tests/client_event.rs +++ b/tests/client_event.rs @@ -6,7 +6,7 @@ use bevy_replicon::prelude::*; use common::{DummyEvent, ReflectEvent, ReflectEventDeserializer, ReflectEventSerializer}; -use crate::common::ReflectEventComponent; +use crate::common::ReflectedValue; #[test] fn without_server_plugin() { @@ -92,7 +92,7 @@ fn sending_receiving_reflect() { let mut client_app = App::new(); for app in [&mut server_app, &mut client_app] { app.add_plugins((MinimalPlugins, ReplicationPlugins)) - .register_type::() + .register_type::() .add_client_reflect_event::( SendPolicy::Ordered, ); @@ -105,7 +105,7 @@ fn sending_receiving_reflect() { .resource_mut::>() .send(ReflectEvent { entity: Entity::PLACEHOLDER, - component: ReflectEventComponent.clone_value(), + reflect: ReflectedValue.clone_value(), }); client_app.update(); @@ -123,7 +123,7 @@ fn mapping_and_sending_receiving_reflect() { let mut client_app = App::new(); for app in [&mut server_app, &mut client_app] { app.add_plugins((MinimalPlugins, ReplicationPlugins)) - .register_type::() + .register_type::() .add_mapped_client_reflect_event::(SendPolicy::Ordered); } @@ -141,7 +141,7 @@ fn mapping_and_sending_receiving_reflect() { .resource_mut::>() .send(ReflectEvent { entity: client_entity, - component: ReflectEventComponent.clone_value(), + reflect: ReflectedValue.clone_value(), }); client_app.update(); diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 1d6ca1da..8d2b8b45 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -128,9 +128,6 @@ fn create_client( (client, transport) } -#[derive(Reflect, Debug)] -pub(super) struct ReflectEventComponent; - #[derive(Debug, Deserialize, Event, Serialize)] pub(super) struct DummyEvent(pub(super) Entity); @@ -141,10 +138,13 @@ impl MapEventEntities for DummyEvent { } } +#[derive(Reflect, Debug)] +pub(super) struct ReflectedValue; + #[derive(Debug, Event)] pub(super) struct ReflectEvent { pub(super) entity: Entity, - pub(super) component: Box, + pub(super) reflect: Box, } impl MapEventEntities for ReflectEvent { @@ -158,7 +158,7 @@ impl MapEventEntities for ReflectEvent { #[strum(serialize_all = "snake_case")] enum ReflectEventField { Entity, - Component, + Reflect, } pub(super) struct ReflectEventSerializer<'a> { @@ -186,7 +186,7 @@ impl Serialize for ReflectEventSerializer<'_> { state.serialize_field(ReflectEventField::Entity.into(), &self.event.entity)?; state.serialize_field( ReflectEventField::Entity.into(), - &ReflectSerializer::new(&*self.event.component, self.registry), + &ReflectSerializer::new(&*self.event.reflect, self.registry), )?; state.end() } @@ -227,11 +227,9 @@ impl<'de> Visitor<'de> for ReflectEventDeserializer<'_> { let entity = seq .next_element()? .ok_or_else(|| de::Error::invalid_length(ReflectEventField::Entity as usize, &self))?; - let component = seq + let reflect = seq .next_element_seed(UntypedReflectDeserializer::new(self.registry))? - .ok_or_else(|| { - de::Error::invalid_length(ReflectEventField::Component as usize, &self) - })?; - Ok(ReflectEvent { entity, component }) + .ok_or_else(|| de::Error::invalid_length(ReflectEventField::Reflect as usize, &self))?; + Ok(ReflectEvent { entity, reflect }) } } diff --git a/tests/server_event.rs b/tests/server_event.rs index 01236d1f..b3ce5acb 100644 --- a/tests/server_event.rs +++ b/tests/server_event.rs @@ -7,7 +7,7 @@ use bevy_replicon::prelude::*; use common::{DummyEvent, ReflectEvent, ReflectEventDeserializer, ReflectEventSerializer}; -use crate::common::ReflectEventComponent; +use crate::common::ReflectedValue; #[test] fn without_server_plugin() { @@ -122,7 +122,7 @@ fn sending_receiving_reflect() { MinimalPlugins, ReplicationPlugins.set(ServerPlugin::new(TickPolicy::Manual)), )) - .register_type::() + .register_type::() .add_server_reflect_event::( SendPolicy::Ordered, ); @@ -148,7 +148,7 @@ fn sending_receiving_reflect() { mode, event: ReflectEvent { entity: Entity::PLACEHOLDER, - component: ReflectEventComponent.clone_value(), + reflect: ReflectedValue.clone_value(), }, }); @@ -173,7 +173,7 @@ fn sending_receiving_and_mapping_reflect() { MinimalPlugins, ReplicationPlugins.set(ServerPlugin::new(TickPolicy::Manual)), )) - .register_type::() + .register_type::() .add_mapped_server_reflect_event::(SendPolicy::Ordered); } @@ -193,7 +193,7 @@ fn sending_receiving_and_mapping_reflect() { mode: SendMode::Broadcast, event: ReflectEvent { entity: server_entity, - component: ReflectEventComponent.clone_value(), + reflect: ReflectedValue.clone_value(), }, });