---
source: froql_macro/src/generator.rs
expression: result
---
{
let invar_1: ::froql::entity_store::Entity = (&player).into();
let world: &World = &world;
let bk = &world.bookkeeping;
let components_0 = [
world.get_component_id::<Unit>(),
world.get_component_id::<Health>(),
bk.get_component_id_unchecked(::std::any::TypeId::of::<::froql::relation::Relation<Attack>>()).flip_target(),
];
let components_1 = [
world.get_component_id::<Unit>(),
bk.get_component_id_unchecked(::std::any::TypeId::of::<::froql::relation::Relation<Attack>>()),
];
let archetype_id_sets = [
bk.matching_archetypes(&components_0, &[]),
Vec::<::froql::archetype::ArchetypeId>::new(),
];
// result set
const VAR_COUNT: usize = 2;
let mut a_refs = [&bk.archetypes[0]; VAR_COUNT];
let mut a_rows = [::froql::archetype::ArchetypeRow(u32::MAX); VAR_COUNT];
// general context for statemachine
let mut current_step = 0;
let mut a_max_rows = [0; VAR_COUNT];
let mut a_next_indexes = [usize::MAX; VAR_COUNT];
let mut col_indexes = [usize::MAX; 5];
let opt_cid_0 = world.get_component_id::<Reputation>();
let mut opt_col_0 = None;
let mut rel_helper_0 = ::froql::query_helper::RelationHelper::new
(components_1[1]);
::std::iter::from_fn(move || { loop { match current_step {
0 => {
{
let (aid, arow) = bk.entities.get_archetype(invar_1);
let a_ref = &mut a_refs[1];
*a_ref = &bk.archetypes[aid.as_index()];
if !a_ref.find_multiple_columns_fallible(&components_1, &mut col_indexes[3..5]) {
return None;
}
a_rows[1] = arow;
opt_col_0 = a_ref.find_column_opt(opt_cid_0);
rel_helper_0.set_col(&a_ref.columns[col_indexes[4]]);
rel_helper_0.set_row(bk, a_rows[1].0);
}
current_step += 2;
}
1 => {
return None;
}
// follow relation
2 => {
const REL_VAR: usize = 0;
const REL_VAR_COMPONENTS: ::std::ops::Range<usize> = 0..3;
if let Some(id) = rel_helper_0.next_related() {
// get aid/row for entity in relation
let (aid, arow) = bk.entities.get_archetype_unchecked(id);
// if in target archetype set => go to next step
if archetype_id_sets[REL_VAR].contains(&aid) {
let a_ref = &mut a_refs[REL_VAR];
*a_ref = &bk.archetypes[aid.as_index()];
a_ref.find_multiple_columns(
&components_0,
&mut col_indexes[REL_VAR_COMPONENTS],
);
a_rows[REL_VAR] = arow;
current_step += 1;
}
} else {
current_step -= 1;
}
}
// yield row
3 => {
current_step -= 1;
return Some(unsafe {
(
::froql::query_helper::coerce_cast::<Unit>(
world,
a_refs[0].columns[col_indexes[0]].get(a_rows[0].0)
).borrow(),
::froql::query_helper::coerce_cast::<Unit>(
world,
a_refs[1].columns[col_indexes[3]].get(a_rows[1].0)
).borrow(),
::froql::query_helper::coerce_cast::<Health>(
world,
a_refs[0].columns[col_indexes[1]].get(a_rows[0].0)
).borrow_mut(),
)
});
}
_ => unreachable!(),
}}})
}