diff --git a/code/apps/client/CMakeLists.txt b/code/apps/client/CMakeLists.txt index 116f25e..0395254 100644 --- a/code/apps/client/CMakeLists.txt +++ b/code/apps/client/CMakeLists.txt @@ -30,6 +30,9 @@ add_library(client-common STATIC ../../common/signal_handling.c ../../common/signal_handling.h + + ../../common/assets.h + ../../common/assets.c ) add_executable(eco2d-client diff --git a/code/apps/server/CMakeLists.txt b/code/apps/server/CMakeLists.txt index 07cc10c..14c7fd2 100644 --- a/code/apps/server/CMakeLists.txt +++ b/code/apps/server/CMakeLists.txt @@ -29,6 +29,9 @@ add_executable(eco2d-server ../../common/signal_handling.c ../../common/signal_handling.h + + ../../common/assets.h + ../../common/assets.c ) include_directories(eco2d-server header) diff --git a/code/apps/server/header/components/general.h b/code/apps/server/header/components/general.h index 714d712..584b551 100644 --- a/code/apps/server/header/components/general.h +++ b/code/apps/server/header/components/general.h @@ -2,13 +2,15 @@ #include "flecs/flecs.h" #include "flecs/flecs_meta.h" +#include "assets.h" + ECS_STRUCT(Vector2D, { int16_t x; int16_t y; }); ECS_STRUCT(Drawable, { - char filename[80]; + uint16_t id; }); typedef Vector2D Chunk; diff --git a/code/apps/server/source/network.c b/code/apps/server/source/network.c index d4fe99c..9ebdbd6 100644 --- a/code/apps/server/source/network.c +++ b/code/apps/server/source/network.c @@ -136,7 +136,7 @@ uint64_t network_client_create(uint16_t peer_id) { ecs_entity_t e = ecs_new(world_ecs(), Player); ecs_add(world_ecs(), e, EcsClient); ecs_set(world_ecs(), e, ClientInfo, {peer_id}); - ecs_set(world_ecs(), e, Drawable, {"player.png"}); + ecs_set(world_ecs(), e, Drawable, {ASSET_PLAYER}); librg_entity_track(world_tracker(), e); librg_entity_owner_set(world_tracker(), e, peer_id); diff --git a/code/common/assets.c b/code/common/assets.c new file mode 100644 index 0000000..b411c01 --- /dev/null +++ b/code/common/assets.c @@ -0,0 +1,5 @@ +#include "assets.h" + +asset_info assets[] = { + {.id = ASSET_PLAYER, .kind = ASSET_KIND_IMAGE, .filename = "player.png"} +}; diff --git a/code/common/assets.h b/code/common/assets.h new file mode 100644 index 0000000..35966f8 --- /dev/null +++ b/code/common/assets.h @@ -0,0 +1,21 @@ +#pragma once +#include "system.h" + +typedef struct { + uint16_t id; + uint8_t kind; + char* filename; +} asset_info; + +enum { + ASSET_KIND_IMAGE, + ASSET_KIND_SOUND, + ASSET_KIND_FORCE_8 = UINT8_MAX, +}; + +enum { + ASSET_PLAYER, + ASSET_FORCE_16 = UINT16_MAX, +}; + +extern asset_info assets[];