Techneck/code/source-c/world.h

82 lines
2.1 KiB
C

#ifndef TC_WORLD_H
#define TC_WORLD_H
#include <stdbool.h>
#include <blocks.h>
#include <hook.h>
#include <physics/simulation.h>
#include <utility/math.h>
#include <entity.h>
#include <chunk.h>
#include <chunk_pool.h>
#define UPDATE_DISTANCE 2
typedef struct tc_block tc_block_s;
typedef struct tc_world tc_world_s;
typedef struct tc_worldgen tc_worldgen_s;
struct tc_worldgen {
char *name;
bool_t (*fn_generate_chunk) (tc_worldgen_s *gen, tc_chunk_s *chunk);
};
struct tc_block
{
u32_t type_identifier;
tc_vec3f_s position;
tc_vec3f_s rotation;
};
struct tc_world
{
tc_chunk_pool_s *pool;
tc_worldgen_s *worldgen;
u32_t num_loaders;
tc_chunkloader_s *loaders;
tc_chunkloader_s *spawn_loader;
tc_physics_simulation_s *physics;
tc_hooklist_s on_chunk_create;
tc_hooklist_s before_chunk_generate;
tc_hooklist_s after_chunk_generate;
tc_hooklist_s on_chunk_delete;
tc_hooklist_s on_chunk_update;
};
extern tc_worldgen_s tc_default_terrain_generator_g;
void tc_init_worlds ();
void tc_draw_world (tc_world_s *world);
tc_world_s * tc_new_world (tc_worldgen_s *generator);
tc_chunk_s * tc_new_chunk (tc_world_s *world, i32_t x, i32_t y, i32_t z); // must be integers
void tc_set_block_in_chunk(
tc_chunk_s *chunk,
u8_t x, u8_t y, u8_t z,
tc_block_s block
);
void tc_update_world (tc_world_s *world);
void tc_unload_world (tc_world_s *world);
bool_t tc_generate_default_terrain_chunk (tc_worldgen_s *gen, tc_chunk_s *chunk);
void tc_create_world_physics (tc_world_s *world, void *userdata);
#endif