From 4fa3837aa20edf51686f8a4a98748b2dbbf17fec Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 3 Apr 2026 20:32:44 -0700 Subject: [PATCH] More docs on merge functions. --- src/registry.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/registry.rs b/src/registry.rs index 20a760b..ed21a03 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -5,6 +5,9 @@ use std::collections::HashMap; /// A function used to merge effects with [`EffectMode::Merge`](crate::EffectMode::Merge), /// which must be registered in the [registry](EffectMergeRegistry). /// +/// The component the function is registered for is guaranteed to exist on both provided entities. +/// Note that the incoming entity exists in a **separate world**. +/// /// # Example /// ```rust /// # use bevy_ecs::prelude::*; @@ -13,8 +16,9 @@ use std::collections::HashMap; /// struct MyEffect(f32); /// /// fn merge_my_effect(mut existing: EntityWorldMut, incoming: EntityRef) { +/// let mut existing = existing.get_mut::().unwrap(); /// let incoming = incoming.get::().unwrap(); -/// existing.get_mut::().unwrap().0 += incoming.0; +/// existing.0 += incoming.0; /// } /// ``` pub type EffectMergeFn = fn(existing: EntityWorldMut, incoming: EntityRef); @@ -38,8 +42,9 @@ pub type EffectMergeFn = fn(existing: EntityWorldMut, incoming: EntityRef); /// } /// /// fn merge_my_effect(mut existing: EntityWorldMut, incoming: EntityRef) { +/// let mut existing = existing.get_mut::().unwrap(); /// let incoming = incoming.get::().unwrap(); -/// existing.get_mut::().unwrap().0 += incoming.0; +/// existing.0 += incoming.0; /// } /// ``` #[derive(Resource, Default)] -- 2.51.2