small changes

isolation_bkp/dynres
Dominik Madarász 2021-08-30 18:14:35 +02:00
parent 32deb322db
commit b45ed4fa75
6 changed files with 10 additions and 22 deletions

View File

@ -21,7 +21,7 @@ ActSpawnCar(void) {
void
ActSpawnIcemaker(void) {
ecs_entity_t e = item_spawn(IKIND_DEMO_ICEMAKER, 1);
ecs_entity_t e = item_spawn(IKIND_DEMO_ICEMAKER, 32);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
@ -63,7 +63,7 @@ ActPlaceIceRink(void) {
for (int y = 0; y < 100; y++) {
for (int x = 0; x < 100; x++) {
world_block_lookup l = world_block_from_realpos((p->x - (x*bs)/2.0f), p->y - (y*bs)/2.0f);
world_chunk_replace_outer_block(l.chunk_id, l.id, watr_id);
world_chunk_replace_block(l.chunk_id, l.id, watr_id);
}
}
@ -79,7 +79,7 @@ ActEraseWorldChanges(void) {
for (int y = 0; y < 100; y++) {
for (int x = 0; x < 100; x++) {
world_block_lookup l = world_block_from_realpos((p->x - (x*bs)/2.0f), p->y - (y*bs)/2.0f);
world_chunk_replace_outer_block(l.chunk_id, l.id, 0);
world_chunk_place_block(l.chunk_id, l.id, 0);
}
}

View File

@ -38,7 +38,7 @@ void item_use(ecs_world_t *ecs, ItemDrop *it, Position p) {
switch (item_get_usage(item_id)) {
case UKIND_PLACE:{
world_block_lookup l = world_block_from_realpos(p.x, p.y);
world_chunk_replace_outer_block(l.chunk_id, l.id, blocks_find(desc->place.biome, desc->place.kind));
if (world_chunk_place_block(l.chunk_id, l.id, blocks_find(desc->place.biome, desc->place.kind)) )
it->quantity--;
}break;
}

View File

@ -5,7 +5,7 @@ static item_desc items[] = {
.kind = IKIND_DEMO_ICEMAKER,
.usage = UKIND_PLACE,
.asset = ASSET_DEMO_ICEMAKER,
.max_quantity = 4,
.max_quantity = 64,
.place = {
.biome = BLOCK_BIOME_DEV,

View File

@ -418,10 +418,12 @@ void world_chunk_replace_block(int64_t id, uint16_t block_idx, uint8_t block_id)
world_chunk_mark_dirty(world.chunk_mapping[id]);
}
void world_chunk_replace_outer_block(int64_t id, uint16_t block_idx, uint8_t block_id) {
bool world_chunk_place_block(int64_t id, uint16_t block_idx, uint8_t block_id) {
ZPL_ASSERT(block_idx >= 0 && block_idx < zpl_square(world.chunk_size));
if (world.outer_block_mapping[id][block_idx] != 0 && block_id != 0) return false;
world.outer_block_mapping[id][block_idx] = block_id;
world_chunk_mark_dirty(world.chunk_mapping[id]);
return true;
}
uint8_t *world_chunk_get_blocks(int64_t id) {

View File

@ -77,7 +77,7 @@ world_block_lookup world_block_from_index(int64_t id, uint16_t block_idx);
int64_t world_chunk_from_realpos(float x, float y);
int64_t world_chunk_from_entity(ecs_entity_t id);
void world_chunk_replace_block(int64_t id, uint16_t block_idx, uint8_t block_id);
void world_chunk_replace_outer_block(int64_t id, uint16_t block_idx, uint8_t block_id);
bool world_chunk_place_block(int64_t id, uint16_t block_idx, uint8_t block_id);
uint8_t *world_chunk_get_blocks(int64_t id);
void world_chunk_mark_dirty(ecs_entity_t e);
uint8_t world_chunk_is_dirty(ecs_entity_t e);

View File

@ -10,17 +10,3 @@ void DemoNPCMoveAround(ecs_iter_t *it) {
v[i].y += (v[i].y*d*DEMO_NPC_MOVE_SPEED + zpl_sin(zpl_to_radians(rand()%360))*DEMO_NPC_STEER_SPEED);
}
}
void DemoPlaceIceBlock(ecs_iter_t *it) {
Input *in = ecs_column(it, Input, 1);
Position *p = ecs_column(it, Position, 2);
uint8_t watr_id = blocks_find(BLOCK_BIOME_DEV, BLOCK_KIND_WATER);
for (int i = 0; i < it->count; i++) {
if (in[i].use) {
in[i].use = false;
world_block_lookup l = world_block_from_realpos(p[i].x, p[i].y);
world_chunk_replace_outer_block(l.chunk_id, l.id, watr_id);
}
}
}