-
Notifications
You must be signed in to change notification settings - Fork 45
Implement exclusive relationships #212
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
base: main
Are you sure you want to change the base?
Conversation
This could be more optimal if you just pass the entity into where the archetype graph is involved and invoke an on_remove hook when necessary. |
Good idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to resolve the merge conflicts
on_remove(entity) | ||
end | ||
end | ||
|
||
-- If there was a previous archetype, then the entity needs to move the archetype | ||
entity_move(entity_index, entity, record, to) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be record.archetype since on_remove can change the archetype it is destined for.
@@ -945,6 +975,13 @@ local function world_set(world: ecs_world_t, entity: i53, id: i53, data: unknown | |||
end | |||
|
|||
if from then | |||
if ECS_IS_PAIR(id) and bit32.band(idr.flags, ECS_ID_EXCLUSIVE) ~= 0 then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is probably cheap enough to just check the flags, you can benchmark and confirm.
But if you want to check if it is a pair first, you should only look up the id_record if the id is a pair.
on_remove(entity) | ||
end | ||
end | ||
|
||
entity_move(entity_index, entity, record, to) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has to be record.archetype not to
because on_remove can cause the entity to move
This PR implements exclusive relationships following flecs' implementation.
For some unknown reason the "#repro2" test now fails. Removing the
world:set(entity, pair(4, 5), 6)
call at line 145 fixes it.