ent: entity_set_position helper
parent
c7d251eb44
commit
16001c24b9
|
@ -45,6 +45,14 @@ void entity_despawn(uint64_t ent_id) {
|
||||||
ecs_delete(world_ecs(), ent_id);
|
ecs_delete(world_ecs(), ent_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void entity_set_position(uint64_t ent_id, float x, float y) {
|
||||||
|
Position *p = ecs_get_mut(world_ecs(), ent_id, Position);
|
||||||
|
p->x = x;
|
||||||
|
p->y = y;
|
||||||
|
|
||||||
|
entity_wake(ent_id);
|
||||||
|
}
|
||||||
|
|
||||||
void entity_wake(uint64_t ent_id) {
|
void entity_wake(uint64_t ent_id) {
|
||||||
StreamInfo *si = ecs_get_mut(world_ecs(), ent_id, StreamInfo);
|
StreamInfo *si = ecs_get_mut(world_ecs(), ent_id, StreamInfo);
|
||||||
si->tick_delay = 0.0f;
|
si->tick_delay = 0.0f;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
uint64_t entity_spawn(uint16_t class_id /* 0 = no streaming */);
|
uint64_t entity_spawn(uint16_t class_id /* 0 = no streaming */);
|
||||||
void entity_batch_despawn(uint64_t *ids, size_t num_ids);
|
void entity_batch_despawn(uint64_t *ids, size_t num_ids);
|
||||||
void entity_despawn(uint64_t ent_id);
|
void entity_despawn(uint64_t ent_id);
|
||||||
|
void entity_set_position(uint64_t ent_id, float x, float y);
|
||||||
|
|
||||||
// NOTE(zaklaus): action-based entity stream throttling
|
// NOTE(zaklaus): action-based entity stream throttling
|
||||||
void entity_wake(uint64_t ent_id);
|
void entity_wake(uint64_t ent_id);
|
||||||
|
|
|
@ -41,9 +41,9 @@ void PickItem(ecs_iter_t *it) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (range <= ITEM_ATTRACT_RADIUS) {
|
} else if (range <= ITEM_ATTRACT_RADIUS) {
|
||||||
p2->x = zpl_lerp(p2->x, p[i].x, ITEM_ATTRACT_FORCE*it->delta_time);
|
entity_set_position(ents[j],
|
||||||
p2->y = zpl_lerp(p2->y, p[i].y, ITEM_ATTRACT_FORCE*it->delta_time);
|
zpl_lerp(p2->x, p[i].x, ITEM_ATTRACT_FORCE*it->delta_time),
|
||||||
entity_wake(ents[j]);
|
zpl_lerp(p2->y, p[i].y, ITEM_ATTRACT_FORCE*it->delta_time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue