bool blocktype_preload(BlockType * self) { { #line 56 LandArrayIterator __iter0__ = LandArrayIterator_first(self->bitmaps); #line 56 for (LandImage * pic = LandArrayIterator_item(self->bitmaps, &__iter0__); LandArrayIterator_next(self->bitmaps, &__iter0__); pic = LandArrayIterator_item(self->bitmaps, &__iter0__)) { if (land_image_load_on_demand(pic)) { return 1; } } } #line 59 return 0; }
void blocktype_destroy(BlockType * self) { if (self->bitmaps) { { #line 50 LandArrayIterator __iter0__ = LandArrayIterator_first(self->bitmaps); #line 50 for (LandImage * pic = LandArrayIterator_item(self->bitmaps, &__iter0__); LandArrayIterator_next(self->bitmaps, &__iter0__); pic = LandArrayIterator_item(self->bitmaps, &__iter0__)) { land_image_destroy(pic); } } #line 52 land_array_destroy(self->bitmaps); } #line 53 land_free(self); }
void actors_tick(Actors * self) { Actor * under_mouse_ally = NULL; Actor * under_mouse_enemy = NULL; Actor * dead = NULL; self->selected = NULL; {LandArrayIterator __iter3__ = LandArrayIterator_first(self->array) ; for (Actor * a = LandArrayIterator_item(self->array, & __iter3__) ; LandArrayIterator_next(self->array, & __iter3__) ; a = LandArrayIterator_item(self->array, & __iter3__)) { if (a->dead && a->anim_tick >= 120) { dead = a; } if (! a->kind) { continue; } if (a->selected) { self->selected = a; } float dx = wrap(a->x - app->mx); int w = a->kind->w; int h = a->kind->h; if (dx >= - w / 2 && dx <= w / 2 && app->my >= a->y - h && app->my <= a->y) { if (a->kind->enemy) { under_mouse_enemy = a; } else { under_mouse_ally = a; } } } } if (dead) { int i = land_array_find(self->array, dead); actor_unplace(dead); land_array_replace_nth(self->array, i, land_array_pop(self->array)); } if (land_mouse_button_clicked(0)) { if (under_mouse_ally) { actors_unselect_all(self); under_mouse_ally->selected = 1; } } if (land_mouse_button_clicked(1)) { bool clicked = 0; if (under_mouse_enemy) { if (self->selected && self->selected->kind->id != AT_HEALER) { self->selected->target = under_mouse_enemy; actor_stop(self->selected); clicked = 1; } } if (under_mouse_ally && ! clicked) { if (self->selected && self->selected->kind->id == AT_HEALER) { self->selected->target = under_mouse_ally; actor_stop(self->selected); clicked = 1; } } if (! clicked) { if (self->selected) { self->selected->tx = app->mx; self->selected->ty = app->my; self->selected->target = NULL; self->selected->walking = 1; } } } {LandArrayIterator __iter4__ = LandArrayIterator_first(self->array) ; for (Actor * a = LandArrayIterator_item(self->array, & __iter4__) ; LandArrayIterator_next(self->array, & __iter4__) ; a = LandArrayIterator_item(self->array, & __iter4__)) { if (! a->kind) { continue; } actor_tick(a); } } }
void actors_unselect_all(Actors * self) { {LandArrayIterator __iter2__ = LandArrayIterator_first(self->array) ; for (Actor * a = LandArrayIterator_item(self->array, & __iter2__) ; LandArrayIterator_next(self->array, & __iter2__) ; a = LandArrayIterator_item(self->array, & __iter2__)) { a->selected = 0; } } }
void actors_draw(Actors * self) { for (int y = 0; y < self->h; y += 1) { for (int x = 0; x < self->w; x += 1) { Item * i = self->tilemap[x + self->w * y] .item; if (i) { item_draw_shadow(i); } LandArray * arr = self->tilemap[x + self->w * y] .actors; if (arr) { {LandArrayIterator __iter0__ = LandArrayIterator_first(arr) ; for (Actor * a = LandArrayIterator_item(arr, & __iter0__) ; LandArrayIterator_next(arr, & __iter0__) ; a = LandArrayIterator_item(arr, & __iter0__)) { actor_draw_shadow(a); } } } } } for (int y = 0; y < self->h; y += 1) { for (int x = 0; x < self->w; x += 1) { Item * i = self->tilemap[x + self->w * y] .item; if (i) { item_draw(i); } LandArray * arr = self->tilemap[x + self->w * y] .actors; if (arr) { {LandArrayIterator __iter1__ = LandArrayIterator_first(arr) ; for (Actor * a = LandArrayIterator_item(arr, & __iter1__) ; LandArrayIterator_next(arr, & __iter1__) ; a = LandArrayIterator_item(arr, & __iter1__)) { actor_draw(a); } } } } } }