item router fix rolling counter
parent
267a60af32
commit
3174b8a3c3
|
@ -46,7 +46,7 @@ void notification_draw(void) {
|
|||
|
||||
for (zpl_isize i = cnt; i >= 0; --i) {
|
||||
notification *notif = (notifications + i);
|
||||
if (nk_begin_titled(game_ui, zpl_bprintf("%dnotif%s", i, notif->title), notif->title, nk_rect(width - 320, ypos, 300, 1200),
|
||||
if (nk_begin_titled(game_ui, zpl_bprintf("%d%fnotif%s", i, ypos, notif->title), notif->title, nk_rect(width - 320, ypos, 300, 1200),
|
||||
NK_WINDOW_DYNAMIC|NK_WINDOW_NO_SCROLLBAR)) {
|
||||
{
|
||||
if (nk_tree_push_id(game_ui, NK_TREE_TAB, notif->title, NK_MAXIMIZED, (int)i)) {
|
||||
|
|
|
@ -157,7 +157,6 @@ void tooltip__draw_node(tooltip_node *node) {
|
|||
nk_layout_row_dynamic(game_ui, 20, 2);
|
||||
|
||||
for (zpl_isize i = 0; i < zpl_array_count(desc->links); ++i) {
|
||||
// todo styling
|
||||
if (nk_button_label(game_ui, desc->links[i])) {
|
||||
if (node->next) tooltip__clear_node(node->next);
|
||||
if (!node->next) node->next = zpl_malloc(sizeof(tooltip_node));
|
||||
|
|
|
@ -156,6 +156,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t push_qty;
|
||||
uint8_t counter;
|
||||
} ItemRouter;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -75,7 +75,6 @@ void PushItemsOnNodes(ecs_iter_t *it) {
|
|||
float push_dx[4], push_dy[4];
|
||||
uint8_t nodes = CheckForNearbyBelts(&p[i], push_dx, push_dy);
|
||||
uint8_t num_nodes = (uint8_t)zpl_count_set_bits(nodes);
|
||||
uint8_t counter = 0;
|
||||
|
||||
if (num_nodes == 0) {
|
||||
// NOTE(zaklaus): We don't have any output nodes yet.
|
||||
|
@ -105,22 +104,22 @@ void PushItemsOnNodes(ecs_iter_t *it) {
|
|||
|
||||
while (item->quantity > 0 && num_nodes > 0) {
|
||||
// NOTE(zaklaus): Use a rolling counter to select an output node.
|
||||
while (!(nodes & (1 << counter)) && counter < 4) ++counter;
|
||||
if (counter > 3) {
|
||||
counter = 0;
|
||||
while (!(nodes & (1 << r[i].counter)) && r[i].counter < 4) ++r[i].counter;
|
||||
if (r[i].counter > 3) {
|
||||
r[i].counter = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
uint64_t e = item_spawn(item->kind, zpl_min(r->push_qty, item->quantity));
|
||||
entity_set_position(e, p[i].x + push_dx[counter], p[i].y + push_dy[counter]);
|
||||
entity_set_position(e, p[i].x + push_dx[r[i].counter], p[i].y + push_dy[r[i].counter]);
|
||||
|
||||
Velocity *e_vel = ecs_get_mut_ex(it->world, e, Velocity);
|
||||
e_vel->x = push_dx[counter];
|
||||
e_vel->y = push_dy[counter];
|
||||
e_vel->x = push_dx[r[i].counter];
|
||||
e_vel->y = push_dy[r[i].counter];
|
||||
|
||||
item->quantity -= zpl_min(r->push_qty, item->quantity);
|
||||
--num_nodes;
|
||||
++counter;
|
||||
++r[i].counter;
|
||||
|
||||
if (item->quantity == 0) {
|
||||
item_despawn(item_slot_ent);
|
||||
|
|
Loading…
Reference in New Issue