From 9218c3bc3b1b82419673a2ebe5255f715ac8762b Mon Sep 17 00:00:00 2001 From: "Dr. Dystopia" Date: Tue, 20 Jul 2021 09:43:52 +0200 Subject: [PATCH] Apply same member order as in trait --- common/net/src/sync/sync_ext.rs | 20 ++--- common/src/states/dance.rs | 12 +-- common/src/states/glide_wield.rs | 24 +++--- common/src/states/idle.rs | 36 ++++----- common/src/states/sit.rs | 12 +-- common/src/states/sneak.rs | 36 ++++----- common/src/states/talk.rs | 12 +-- common/src/states/wielding.rs | 60 +++++++------- voxygen/anim/src/fixture/mod.rs | 4 +- .../ui/ice/widget/aspect_ratio_container.rs | 38 ++++----- .../src/ui/ice/widget/background_container.rs | 38 ++++----- voxygen/src/ui/ice/widget/mouse_detector.rs | 38 ++++----- voxygen/src/ui/ice/widget/overlay.rs | 70 ++++++++--------- voxygen/src/ui/ice/widget/tooltip.rs | 78 +++++++++---------- 14 files changed, 239 insertions(+), 239 deletions(-) diff --git a/common/net/src/sync/sync_ext.rs b/common/net/src/sync/sync_ext.rs index f2256bd3c9..e1b508a9ad 100644 --- a/common/net/src/sync/sync_ext.rs +++ b/common/net/src/sync/sync_ext.rs @@ -61,6 +61,16 @@ impl WorldSyncExt for specs::World { self.create_entity().marked::() } + fn delete_entity_and_clear_from_uid_allocator(&mut self, uid: u64) { + // Clear from uid allocator + let maybe_entity = self.write_resource::().remove_entity(uid); + if let Some(entity) = maybe_entity { + if let Err(e) = self.delete_entity(entity) { + error!(?e, "Failed to delete entity"); + } + } + } + /// Get the UID of an entity fn uid_from_entity(&self, entity: specs::Entity) -> Option { self.read_storage::().get(entity).copied() @@ -86,16 +96,6 @@ impl WorldSyncExt for specs::World { entity } - fn delete_entity_and_clear_from_uid_allocator(&mut self, uid: u64) { - // Clear from uid allocator - let maybe_entity = self.write_resource::().remove_entity(uid); - if let Some(entity) = maybe_entity { - if let Err(e) = self.delete_entity(entity) { - error!(?e, "Failed to delete entity"); - } - } - } - fn apply_entity_sync_package(&mut self, package: EntitySyncPackage) { // Take ownership of the fields let EntitySyncPackage { diff --git a/common/src/states/dance.rs b/common/src/states/dance.rs index b053a87092..8a13b84d10 100644 --- a/common/src/states/dance.rs +++ b/common/src/states/dance.rs @@ -23,6 +23,12 @@ impl CharacterBehavior for Data { update } + fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { + let mut update = StateUpdate::from(data); + handle_manipulate_loadout(data, &mut update, inv_action); + update + } + fn wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_wield(data, &mut update); @@ -41,10 +47,4 @@ impl CharacterBehavior for Data { update.character = CharacterState::Idle; update } - - fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { - let mut update = StateUpdate::from(data); - handle_manipulate_loadout(data, &mut update, inv_action); - update - } } diff --git a/common/src/states/glide_wield.rs b/common/src/states/glide_wield.rs index 76ef7d51a6..25c36d1c39 100644 --- a/common/src/states/glide_wield.rs +++ b/common/src/states/glide_wield.rs @@ -38,6 +38,18 @@ impl CharacterBehavior for Data { update } + fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { + let mut update = StateUpdate::from(data); + handle_manipulate_loadout(data, &mut update, inv_action); + update + } + + fn unwield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + update.character = CharacterState::Idle; + update + } + fn sit(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_sit(data, &mut update); @@ -55,16 +67,4 @@ impl CharacterBehavior for Data { attempt_sneak(data, &mut update); update } - - fn unwield(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - update.character = CharacterState::Idle; - update - } - - fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { - let mut update = StateUpdate::from(data); - handle_manipulate_loadout(data, &mut update, inv_action); - update - } } diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index d715a33531..1834677354 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -20,21 +20,33 @@ impl CharacterBehavior for Data { update } + fn swap_equipped_weapons(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_swap_equipped_weapons(data, &mut update); + update + } + + fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { + let mut update = StateUpdate::from(data); + handle_manipulate_loadout(data, &mut update, inv_action); + update + } + fn wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_wield(data, &mut update); update } - fn sit(&self, data: &JoinData) -> StateUpdate { + fn glide_wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - attempt_sit(data, &mut update); + attempt_glide_wield(data, &mut update); update } - fn talk(&self, data: &JoinData) -> StateUpdate { + fn sit(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - attempt_talk(data, &mut update); + attempt_sit(data, &mut update); update } @@ -50,21 +62,9 @@ impl CharacterBehavior for Data { update } - fn glide_wield(&self, data: &JoinData) -> StateUpdate { + fn talk(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - attempt_glide_wield(data, &mut update); - update - } - - fn swap_equipped_weapons(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - attempt_swap_equipped_weapons(data, &mut update); - update - } - - fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { - let mut update = StateUpdate::from(data); - handle_manipulate_loadout(data, &mut update, inv_action); + attempt_talk(data, &mut update); update } } diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index f78863e4bc..afafb3e743 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -23,6 +23,12 @@ impl CharacterBehavior for Data { update } + fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { + let mut update = StateUpdate::from(data); + handle_manipulate_loadout(data, &mut update, inv_action); + update + } + fn wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_wield(data, &mut update); @@ -41,10 +47,4 @@ impl CharacterBehavior for Data { update.character = CharacterState::Idle; update } - - fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { - let mut update = StateUpdate::from(data); - handle_manipulate_loadout(data, &mut update, inv_action); - update - } } diff --git a/common/src/states/sneak.rs b/common/src/states/sneak.rs index 988a09cf3b..bc4c6566ba 100644 --- a/common/src/states/sneak.rs +++ b/common/src/states/sneak.rs @@ -25,12 +25,30 @@ impl CharacterBehavior for Data { update } + fn swap_equipped_weapons(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_swap_equipped_weapons(data, &mut update); + update + } + + fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { + let mut update = StateUpdate::from(data); + handle_manipulate_loadout(data, &mut update, inv_action); + update + } + fn wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_wield(data, &mut update); update } + fn glide_wield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_glide_wield(data, &mut update); + update + } + fn sit(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_sit(data, &mut update); @@ -43,27 +61,9 @@ impl CharacterBehavior for Data { update } - fn glide_wield(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - attempt_glide_wield(data, &mut update); - update - } - - fn swap_equipped_weapons(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - attempt_swap_equipped_weapons(data, &mut update); - update - } - fn stand(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); update.character = CharacterState::Idle; update } - - fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { - let mut update = StateUpdate::from(data); - handle_manipulate_loadout(data, &mut update, inv_action); - update - } } diff --git a/common/src/states/talk.rs b/common/src/states/talk.rs index f03e77c352..21b15dd129 100644 --- a/common/src/states/talk.rs +++ b/common/src/states/talk.rs @@ -20,6 +20,12 @@ impl CharacterBehavior for Data { update } + fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { + let mut update = StateUpdate::from(data); + handle_manipulate_loadout(data, &mut update, inv_action); + update + } + fn wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_wield(data, &mut update); @@ -46,10 +52,4 @@ impl CharacterBehavior for Data { update.character = CharacterState::Idle; update } - - fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate { - let mut update = StateUpdate::from(data); - handle_manipulate_loadout(data, &mut update, inv_action); - update - } } diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index e7c6469873..81a0bc860c 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -21,36 +21,6 @@ impl CharacterBehavior for Data { update } - fn sit(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - attempt_sit(data, &mut update); - update - } - - fn dance(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - attempt_dance(data, &mut update); - update - } - - fn sneak(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - attempt_sneak(data, &mut update); - update - } - - fn unwield(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - update.character = CharacterState::Idle; - update - } - - fn glide_wield(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - attempt_glide_wield(data, &mut update); - update - } - fn swap_equipped_weapons(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_swap_equipped_weapons(data, &mut update); @@ -73,4 +43,34 @@ impl CharacterBehavior for Data { handle_manipulate_loadout(data, &mut update, inv_action); update } + + fn glide_wield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_glide_wield(data, &mut update); + update + } + + fn unwield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + update.character = CharacterState::Idle; + update + } + + fn sit(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sit(data, &mut update); + update + } + + fn dance(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_dance(data, &mut update); + update + } + + fn sneak(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sneak(data, &mut update); + update + } } diff --git a/voxygen/anim/src/fixture/mod.rs b/voxygen/anim/src/fixture/mod.rs index 26f310ae2a..89b88b6da4 100644 --- a/voxygen/anim/src/fixture/mod.rs +++ b/voxygen/anim/src/fixture/mod.rs @@ -10,11 +10,11 @@ pub struct SkeletonAttr; impl<'a, Factor> Lerp for &'a FixtureSkeleton { type Output = FixtureSkeleton; + fn lerp_unclamped(_from: Self, _to: Self, _factor: Factor) -> Self::Output { FixtureSkeleton } + fn lerp_unclamped_precise(_from: Self, _to: Self, _factor: Factor) -> Self::Output { FixtureSkeleton } - - fn lerp_unclamped(_from: Self, _to: Self, _factor: Factor) -> Self::Output { FixtureSkeleton } } impl Skeleton for FixtureSkeleton { diff --git a/voxygen/src/ui/ice/widget/aspect_ratio_container.rs b/voxygen/src/ui/ice/widget/aspect_ratio_container.rs index e420f22441..0c3792ecf4 100644 --- a/voxygen/src/ui/ice/widget/aspect_ratio_container.rs +++ b/voxygen/src/ui/ice/widget/aspect_ratio_container.rs @@ -114,25 +114,6 @@ where layout::Node::with_children(limits.max(), vec![content]) } - fn on_event( - &mut self, - event: Event, - layout: Layout<'_>, - cursor_position: Point, - renderer: &R, - clipboard: &mut dyn Clipboard, - messages: &mut Vec, - ) -> iced::event::Status { - self.content.on_event( - event, - layout.children().next().unwrap(), - cursor_position, - renderer, - clipboard, - messages, - ) - } - fn draw( &self, renderer: &mut R, @@ -163,6 +144,25 @@ where self.content.hash_layout(state); } + fn on_event( + &mut self, + event: Event, + layout: Layout<'_>, + cursor_position: Point, + renderer: &R, + clipboard: &mut dyn Clipboard, + messages: &mut Vec, + ) -> iced::event::Status { + self.content.on_event( + event, + layout.children().next().unwrap(), + cursor_position, + renderer, + clipboard, + messages, + ) + } + fn overlay(&mut self, layout: Layout<'_>) -> Option> { self.content.overlay(layout.children().next().unwrap()) } diff --git a/voxygen/src/ui/ice/widget/background_container.rs b/voxygen/src/ui/ice/widget/background_container.rs index 53de3a647d..0b64becccf 100644 --- a/voxygen/src/ui/ice/widget/background_container.rs +++ b/voxygen/src/ui/ice/widget/background_container.rs @@ -250,25 +250,6 @@ where layout::Node::with_children(size, vec![content]) } - fn on_event( - &mut self, - event: Event, - layout: Layout<'_>, - cursor_position: Point, - renderer: &R, - clipboard: &mut dyn Clipboard, - messages: &mut Vec, - ) -> iced::event::Status { - self.content.on_event( - event, - layout.children().next().unwrap(), - cursor_position, - renderer, - clipboard, - messages, - ) - } - fn draw( &self, renderer: &mut R, @@ -303,6 +284,25 @@ where self.content.hash_layout(state); } + fn on_event( + &mut self, + event: Event, + layout: Layout<'_>, + cursor_position: Point, + renderer: &R, + clipboard: &mut dyn Clipboard, + messages: &mut Vec, + ) -> iced::event::Status { + self.content.on_event( + event, + layout.children().next().unwrap(), + cursor_position, + renderer, + clipboard, + messages, + ) + } + fn overlay(&mut self, layout: Layout<'_>) -> Option> { self.content.overlay(layout.children().next().unwrap()) } diff --git a/voxygen/src/ui/ice/widget/mouse_detector.rs b/voxygen/src/ui/ice/widget/mouse_detector.rs index 036a2f19a9..e4cbb0f57c 100644 --- a/voxygen/src/ui/ice/widget/mouse_detector.rs +++ b/voxygen/src/ui/ice/widget/mouse_detector.rs @@ -43,6 +43,25 @@ where layout::Node::new(limits.resolve(Size::ZERO)) } + fn draw( + &self, + renderer: &mut R, + _defaults: &R::Defaults, + layout: Layout<'_>, + _cursor_position: Point, + _viewport: &Rectangle, + ) -> R::Output { + renderer.draw(layout.bounds()) + } + + fn hash_layout(&self, state: &mut Hasher) { + struct Marker; + std::any::TypeId::of::().hash(state); + + self.width.hash(state); + self.height.hash(state); + } + fn on_event( &mut self, event: Event, @@ -68,25 +87,6 @@ where iced::event::Status::Ignored } - - fn draw( - &self, - renderer: &mut R, - _defaults: &R::Defaults, - layout: Layout<'_>, - _cursor_position: Point, - _viewport: &Rectangle, - ) -> R::Output { - renderer.draw(layout.bounds()) - } - - fn hash_layout(&self, state: &mut Hasher) { - struct Marker; - std::any::TypeId::of::().hash(state); - - self.width.hash(state); - self.height.hash(state); - } } pub trait Renderer: iced::Renderer { diff --git a/voxygen/src/ui/ice/widget/overlay.rs b/voxygen/src/ui/ice/widget/overlay.rs index 0bcd0d3833..093fbd1bea 100644 --- a/voxygen/src/ui/ice/widget/overlay.rs +++ b/voxygen/src/ui/ice/widget/overlay.rs @@ -130,6 +130,41 @@ where layout::Node::with_children(size, vec![over, under]) } + fn draw( + &self, + renderer: &mut R, + defaults: &R::Defaults, + layout: Layout<'_>, + cursor_position: Point, + viewport: &Rectangle, + ) -> R::Output { + let mut children = layout.children(); + renderer.draw( + defaults, + layout.bounds(), + cursor_position, + viewport, + &self.over, + children.next().unwrap(), + &self.under, + children.next().unwrap(), + ) + } + + fn hash_layout(&self, state: &mut Hasher) { + struct Marker; + std::any::TypeId::of::().hash(state); + + self.padding.hash(state); + self.width.hash(state); + self.height.hash(state); + self.max_width.hash(state); + self.max_height.hash(state); + + self.over.hash_layout(state); + self.under.hash_layout(state); + } + fn on_event( &mut self, event: Event, @@ -172,41 +207,6 @@ where } } - fn draw( - &self, - renderer: &mut R, - defaults: &R::Defaults, - layout: Layout<'_>, - cursor_position: Point, - viewport: &Rectangle, - ) -> R::Output { - let mut children = layout.children(); - renderer.draw( - defaults, - layout.bounds(), - cursor_position, - viewport, - &self.over, - children.next().unwrap(), - &self.under, - children.next().unwrap(), - ) - } - - fn hash_layout(&self, state: &mut Hasher) { - struct Marker; - std::any::TypeId::of::().hash(state); - - self.padding.hash(state); - self.width.hash(state); - self.height.hash(state); - self.max_width.hash(state); - self.max_height.hash(state); - - self.over.hash_layout(state); - self.under.hash_layout(state); - } - fn overlay(&mut self, layout: Layout<'_>) -> Option> { let mut children = layout.children(); let (over, under) = (&mut self.over, &mut self.under); diff --git a/voxygen/src/ui/ice/widget/tooltip.rs b/voxygen/src/ui/ice/widget/tooltip.rs index 7ef1e58a42..b7502c5ffe 100644 --- a/voxygen/src/ui/ice/widget/tooltip.rs +++ b/voxygen/src/ui/ice/widget/tooltip.rs @@ -184,25 +184,6 @@ where self.content.layout(renderer, limits) } - fn on_event( - &mut self, - event: Event, - layout: Layout<'_>, - cursor_position: Point, - renderer: &R, - clipboard: &mut dyn Clipboard, - messages: &mut Vec, - ) -> iced::event::Status { - self.content.on_event( - event, - layout, - cursor_position, - renderer, - clipboard, - messages, - ) - } - fn draw( &self, renderer: &mut R, @@ -228,6 +209,31 @@ where .draw(renderer, defaults, layout, cursor_position, viewport) } + fn hash_layout(&self, state: &mut Hasher) { + struct Marker; + std::any::TypeId::of::().hash(state); + self.content.hash_layout(state); + } + + fn on_event( + &mut self, + event: Event, + layout: Layout<'_>, + cursor_position: Point, + renderer: &R, + clipboard: &mut dyn Clipboard, + messages: &mut Vec, + ) -> iced::event::Status { + self.content.on_event( + event, + layout, + cursor_position, + renderer, + clipboard, + messages, + ) + } + fn overlay(&mut self, layout: Layout<'_>) -> Option> { let bounds = layout.bounds(); let aabr = aabr_from_bounds(bounds); @@ -244,12 +250,6 @@ where ) }) } - - fn hash_layout(&self, state: &mut Hasher) { - struct Marker; - std::any::TypeId::of::().hash(state); - self.content.hash_layout(state); - } } impl<'a, M, R> From> for Element<'a, M, R> @@ -332,20 +332,6 @@ where node } - fn hash_layout(&self, state: &mut Hasher, position: Point) { - struct Marker; - std::any::TypeId::of::().hash(state); - - (position.x as u32).hash(state); - (position.y as u32).hash(state); - (self.cursor_position.x as u32).hash(state); - (self.avoid.x as u32).hash(state); - (self.avoid.y as u32).hash(state); - (self.avoid.height as u32).hash(state); - (self.avoid.width as u32).hash(state); - self.content.hash_layout(state); - } - fn draw( &self, renderer: &mut R, @@ -362,6 +348,20 @@ where layout, ) } + + fn hash_layout(&self, state: &mut Hasher, position: Point) { + struct Marker; + std::any::TypeId::of::().hash(state); + + (position.x as u32).hash(state); + (position.y as u32).hash(state); + (self.cursor_position.x as u32).hash(state); + (self.avoid.x as u32).hash(state); + (self.avoid.y as u32).hash(state); + (self.avoid.height as u32).hash(state); + (self.avoid.width as u32).hash(state); + self.content.hash_layout(state); + } } pub trait Renderer: iced::Renderer {