2021-05-06 15:30:38 +00:00
|
|
|
#pragma once
|
2022-09-27 12:56:48 +00:00
|
|
|
#include "platform/system.h"
|
|
|
|
#include "world/entity_view.h"
|
2021-05-06 15:30:38 +00:00
|
|
|
#include "world/world.h"
|
|
|
|
|
|
|
|
typedef struct {
|
2021-05-07 14:43:54 +00:00
|
|
|
uint16_t view_id;
|
2021-05-06 15:30:38 +00:00
|
|
|
uint64_t owner_id;
|
|
|
|
entity_view_tbl entities;
|
|
|
|
librg_world *tracker;
|
2022-10-16 10:30:50 +00:00
|
|
|
|
2021-08-30 17:39:25 +00:00
|
|
|
uint32_t seed;
|
2021-05-06 18:24:01 +00:00
|
|
|
uint32_t size;
|
2022-10-16 10:30:50 +00:00
|
|
|
uint32_t dim, chk_dim;
|
2021-05-06 18:24:01 +00:00
|
|
|
uint16_t chunk_size;
|
2021-05-08 06:55:12 +00:00
|
|
|
uint16_t chunk_amount;
|
2022-10-16 10:30:50 +00:00
|
|
|
|
|
|
|
block_id **block_mapping;
|
|
|
|
block_id **outer_block_mapping;
|
|
|
|
entity_view **chunk_mapping;
|
|
|
|
|
2021-05-09 13:52:46 +00:00
|
|
|
// NOTE(zaklaus): metrics
|
2021-11-04 14:43:23 +00:00
|
|
|
float last_update[WORLD_TRACKER_LAYERS];
|
|
|
|
float delta_time[WORLD_TRACKER_LAYERS];
|
2021-05-09 13:52:46 +00:00
|
|
|
uint8_t active_layer_id;
|
2021-05-06 15:30:38 +00:00
|
|
|
} world_view;
|
|
|
|
|
2021-05-07 14:43:54 +00:00
|
|
|
world_view world_view_create(uint16_t view_id);
|
2021-08-30 17:39:25 +00:00
|
|
|
void world_view_init(world_view *view, uint32_t seed, uint64_t ent_id, uint16_t chunk_size, uint16_t chunk_amount);
|
2021-05-06 15:30:38 +00:00
|
|
|
void world_view_destroy(world_view *view);
|
2022-10-16 10:30:50 +00:00
|
|
|
|
|
|
|
void world_view_setup_chunk(world_view *view, entity_view *chk);
|
|
|
|
void world_view_clear_chunk(world_view *view, entity_view *chk);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16_t id;
|
|
|
|
block_id bid;
|
|
|
|
entity_view* chunk_e;
|
|
|
|
int64_t chunk_id;
|
|
|
|
float ox, oy;
|
|
|
|
float aox, aoy;
|
|
|
|
bool is_outer;
|
|
|
|
} world_view_block_lookup;
|
|
|
|
|
|
|
|
world_view_block_lookup world_view_block_from_realpos(world_view *view, float x, float y);
|