diff --git a/code/foundation/CMakeLists.txt b/code/foundation/CMakeLists.txt index 3c10096..fda4b84 100644 --- a/code/foundation/CMakeLists.txt +++ b/code/foundation/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(eco2d-foundation STATIC src/platform/signal_handling.c src/platform/profiler.c + src/models/assets.c src/models/components.c src/models/items.c src/models/entity.c @@ -36,8 +37,6 @@ add_library(eco2d-foundation STATIC src/world/entity_view.c src/world/prediction.c - src/gen/assets.c - src/systems/systems.c ${PKT_SRCS} diff --git a/code/foundation/src/gen/texgen.h b/code/foundation/src/gen/texgen.h index 5758b89..0a7fb5f 100644 --- a/code/foundation/src/gen/texgen.h +++ b/code/foundation/src/gen/texgen.h @@ -2,7 +2,7 @@ #include "platform/system.h" #include "raylib.h" #include "world/blocks.h" -#include "gen/assets.h" +#include "models/assets.h" Texture2D texgen_build_anim(asset_id id, int64_t counter); Texture2D texgen_build_sprite(asset_id id); diff --git a/code/foundation/src/gen/assets.h b/code/foundation/src/lists/assets_ids.h similarity index 59% rename from code/foundation/src/gen/assets.h rename to code/foundation/src/lists/assets_ids.h index a7715f1..997266c 100644 --- a/code/foundation/src/gen/assets.h +++ b/code/foundation/src/lists/assets_ids.h @@ -1,5 +1,4 @@ #pragma once -#include "platform/system.h" #define ASSET_INVALID 0xFF @@ -45,25 +44,3 @@ typedef enum { MAX_ASSETS = 1024, } asset_id; - -typedef enum { - AKIND_TEXTURE, - AKIND_ANIM, - AKIND_SOUND, - - FORCE_AKIND_UINT8 = UINT8_MAX -} asset_kind; - -int32_t assets_setup(void); -int32_t assets_frame(void); -void assets_destroy(void); - -uint16_t assets_find(asset_id id); - -asset_kind assets_get_kind(uint16_t id); -void *assets_get_snd(uint16_t id); -void *assets_get_tex(uint16_t id); - -// NOTE(zaklaus): client only -#define ASSET_SRC_RECT() ((Rectangle){0, 0, 64, 64}) -#define ASSET_DST_RECT(x,y) ((Rectangle){x, y, 64, 64}) diff --git a/code/foundation/src/gen/assets_list.c b/code/foundation/src/lists/assets_list.c similarity index 97% rename from code/foundation/src/gen/assets_list.c rename to code/foundation/src/lists/assets_list.c index 92a9477..19402c1 100644 --- a/code/foundation/src/gen/assets_list.c +++ b/code/foundation/src/lists/assets_list.c @@ -1,4 +1,4 @@ -#include "gen/assets.h" +#include "models/assets.h" #define ASSET_ENTRY(asset, asset_kind)\ {\ diff --git a/code/foundation/src/world/blocks_list.c b/code/foundation/src/lists/blocks_list.c similarity index 100% rename from code/foundation/src/world/blocks_list.c rename to code/foundation/src/lists/blocks_list.c diff --git a/code/foundation/src/models/entity_spawnlist.c b/code/foundation/src/lists/entity_spawnlist.c similarity index 100% rename from code/foundation/src/models/entity_spawnlist.c rename to code/foundation/src/lists/entity_spawnlist.c diff --git a/code/foundation/src/models/items_list.c b/code/foundation/src/lists/items_list.c similarity index 100% rename from code/foundation/src/models/items_list.c rename to code/foundation/src/lists/items_list.c diff --git a/code/foundation/src/models/items_list_helpers.h b/code/foundation/src/lists/items_list_helpers.h similarity index 100% rename from code/foundation/src/models/items_list_helpers.h rename to code/foundation/src/lists/items_list_helpers.h diff --git a/code/foundation/src/gen/asset_setup.h b/code/foundation/src/models/asset_setup.h similarity index 95% rename from code/foundation/src/gen/asset_setup.h rename to code/foundation/src/models/asset_setup.h index 8375903..2267cdd 100644 --- a/code/foundation/src/gen/asset_setup.h +++ b/code/foundation/src/models/asset_setup.h @@ -4,7 +4,7 @@ // use your favorite editor to quickly navigate between various files. // 1) Register a new Asset ID -#include "gen/assets.h" +#include "models/assets.h" // 2) Add the asset to the asset list #include "assets_list.c" diff --git a/code/foundation/src/gen/assets.c b/code/foundation/src/models/assets.c similarity index 97% rename from code/foundation/src/gen/assets.c rename to code/foundation/src/models/assets.c index a751f07..c17d574 100644 --- a/code/foundation/src/gen/assets.c +++ b/code/foundation/src/models/assets.c @@ -1,4 +1,4 @@ -#include "gen/assets.h" +#include "models/assets.h" #include "raylib.h" #include "gen/texgen.h" @@ -16,7 +16,7 @@ typedef struct { // NOTE(zaklaus): metadata } asset; -#include "assets_list.c" +#include "lists/assets_list.c" #define ASSET_FRAME_RENDER_MS (1.0/5.0) #define ASSET_FRAME_SKIP 4 diff --git a/code/foundation/src/models/assets.h b/code/foundation/src/models/assets.h new file mode 100644 index 0000000..03115fd --- /dev/null +++ b/code/foundation/src/models/assets.h @@ -0,0 +1,26 @@ +#pragma once +#include "platform/system.h" + +#include "lists/assets_ids.h" + +typedef enum { + AKIND_TEXTURE, + AKIND_ANIM, + AKIND_SOUND, + + FORCE_AKIND_UINT8 = UINT8_MAX +} asset_kind; + +int32_t assets_setup(void); +int32_t assets_frame(void); +void assets_destroy(void); + +uint16_t assets_find(asset_id id); + +asset_kind assets_get_kind(uint16_t id); +void *assets_get_snd(uint16_t id); +void *assets_get_tex(uint16_t id); + +// NOTE(zaklaus): client only +#define ASSET_SRC_RECT() ((Rectangle){0, 0, 64, 64}) +#define ASSET_DST_RECT(x,y) ((Rectangle){x, y, 64, 64}) diff --git a/code/foundation/src/models/components.h b/code/foundation/src/models/components.h index bc7de00..8f61f83 100644 --- a/code/foundation/src/models/components.h +++ b/code/foundation/src/models/components.h @@ -1,6 +1,6 @@ #pragma once #include "flecs.h" -#include "gen/assets.h" +#include "models/assets.h" #define ecs_get_mut_ex(world, entity, T) \ (ECS_CAST(T*, world_component_cached(world, entity, ecs_id(T)))) diff --git a/code/foundation/src/models/device.h b/code/foundation/src/models/device.h index 60d1f47..fc43aaf 100644 --- a/code/foundation/src/models/device.h +++ b/code/foundation/src/models/device.h @@ -1,6 +1,6 @@ #pragma once #include "platform/system.h" -#include "gen/assets.h" +#include "models/assets.h" uint64_t device_spawn(asset_id id); void device_despawn(uint64_t ent_id); diff --git a/code/foundation/src/models/entity.c b/code/foundation/src/models/entity.c index 7ea3dfe..13be9a1 100644 --- a/code/foundation/src/models/entity.c +++ b/code/foundation/src/models/entity.c @@ -9,7 +9,7 @@ #include "zpl.h" // NOTE(zaklaus): bring in entity spawnlist -#include "entity_spawnlist.c" +#include "lists/entity_spawnlist.c" uint64_t entity_spawn(uint16_t class_id) { ecs_entity_t e = ecs_new(world_ecs(), 0); diff --git a/code/foundation/src/models/items.c b/code/foundation/src/models/items.c index 0b17681..5379172 100644 --- a/code/foundation/src/models/items.c +++ b/code/foundation/src/models/items.c @@ -8,7 +8,7 @@ #include "zpl.h" -#include "items_list.c" +#include "lists/items_list.c" #define ITEMS_COUNT (sizeof(items)/sizeof(item_desc)) static inline item_id item_resolve_proxy(item_id id) { diff --git a/code/foundation/src/models/items.h b/code/foundation/src/models/items.h index 699b49d..da58730 100644 --- a/code/foundation/src/models/items.h +++ b/code/foundation/src/models/items.h @@ -1,6 +1,6 @@ #pragma once #include "platform/system.h" -#include "gen/assets.h" +#include "models/assets.h" #include "world/blocks.h" #include "models/components.h" diff --git a/code/foundation/src/utils/raylib_helpers.h b/code/foundation/src/utils/raylib_helpers.h index e96100e..1c3f0f7 100644 --- a/code/foundation/src/utils/raylib_helpers.h +++ b/code/foundation/src/utils/raylib_helpers.h @@ -3,7 +3,7 @@ #include "platform/system.h" #include "raylib.h" #include "world/blocks.h" -#include "gen/assets.h" +#include "models/assets.h" #define RAYLIB_NEW_RLGL #include "rlgl.h" diff --git a/code/foundation/src/world/blocks.c b/code/foundation/src/world/blocks.c index a157d2d..66dbe0e 100644 --- a/code/foundation/src/world/blocks.c +++ b/code/foundation/src/world/blocks.c @@ -34,7 +34,7 @@ typedef struct { block_id slot; } block; -#include "blocks_list.c" +#include "lists/blocks_list.c" int32_t blocks_setup(void) { for (block_id i=0; i