-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Relationships (non-fragmenting, one-to-many) #17398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
f401fb3
961ea73
dd999c7
c383baf
1492844
b4798f2
44eb8b9
0bd10cd
c38bc9c
0052080
cf86a92
bdacea7
060a3fb
55864c0
f1988d9
a051983
e823d1c
c69070d
cae5020
7aab4af
0d6cffb
a6ebc65
3cee622
b9efb1a
30723bc
ac94d66
74eaf36
6634492
ab00b6d
3e84a87
966ebca
ec626d6
5851993
874a310
504b105
626d35a
3799b57
7865248
da8874c
a2d0e57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,9 @@ pub fn derive_component(input: TokenStream) -> TokenStream { | |
let on_add = hook_register_function_call(quote! {on_add}, attrs.on_add); | ||
let on_insert = hook_register_function_call(quote! {on_insert}, attrs.on_insert); | ||
let on_replace = hook_register_function_call(quote! {on_replace}, attrs.on_replace); | ||
let on_remove = hook_register_function_call(quote! {on_remove}, attrs.on_remove); | ||
let on_remove: Option<TokenStream2> = | ||
hook_register_function_call(quote! {on_remove}, attrs.on_remove); | ||
let on_despawn = hook_register_function_call(quote! {on_despawn}, attrs.on_despawn); | ||
|
||
ast.generics | ||
.make_where_clause() | ||
|
@@ -160,6 +162,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream { | |
#on_insert | ||
#on_replace | ||
#on_remove | ||
#on_despawn | ||
} | ||
|
||
fn get_component_clone_handler() -> #bevy_ecs_path::component::ComponentCloneHandler { | ||
|
@@ -207,6 +210,7 @@ pub const ON_ADD: &str = "on_add"; | |
pub const ON_INSERT: &str = "on_insert"; | ||
pub const ON_REPLACE: &str = "on_replace"; | ||
pub const ON_REMOVE: &str = "on_remove"; | ||
pub const ON_DESPAWN: &str = "on_despawn"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can benchmark, but I don't expect significant degradation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't expect any problems either, agreed.
cart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
pub const IMMUTABLE: &str = "immutable"; | ||
|
||
|
@@ -217,6 +221,7 @@ struct Attrs { | |
on_insert: Option<ExprPath>, | ||
on_replace: Option<ExprPath>, | ||
on_remove: Option<ExprPath>, | ||
on_despawn: Option<ExprPath>, | ||
immutable: bool, | ||
} | ||
|
||
|
@@ -247,6 +252,7 @@ fn parse_component_attr(ast: &DeriveInput) -> Result<Attrs> { | |
on_insert: None, | ||
on_replace: None, | ||
on_remove: None, | ||
on_despawn: None, | ||
requires: None, | ||
immutable: false, | ||
}; | ||
|
@@ -278,6 +284,9 @@ fn parse_component_attr(ast: &DeriveInput) -> Result<Attrs> { | |
} else if nested.path.is_ident(ON_REMOVE) { | ||
attrs.on_remove = Some(nested.value()?.parse::<ExprPath>()?); | ||
Ok(()) | ||
} else if nested.path.is_ident(ON_DESPAWN) { | ||
attrs.on_despawn = Some(nested.value()?.parse::<ExprPath>()?); | ||
Ok(()) | ||
} else if nested.path.is_ident(IMMUTABLE) { | ||
attrs.immutable = true; | ||
Ok(()) | ||
|
Uh oh!
There was an error while loading. Please reload this page.