small asset ids changes

efd/v1
Dominik Madarász 2022-10-18 09:22:11 +02:00
parent 9e368527a3
commit 3a008427f6
10 changed files with 89 additions and 47 deletions

View File

@ -20,6 +20,7 @@ add_library(eco2d-foundation STATIC
src/models/prefabs/storage.c
src/models/prefabs/furnace.c
src/models/prefabs/blueprint.c
src/models/prefabs/craftbench.c
src/pkt/packet.c

View File

@ -45,6 +45,7 @@ Texture2D texgen_build_sprite_fallback(asset_id id) {
// NOTE(zaklaus): devices
case ASSET_CHEST: return LoadTexEco("chest");
case ASSET_FURNACE: return LoadTexEco("furnace-export");
case ASSET_CRAFTBENCH: return LoadTexEco("craftbench");
default: break;
}

View File

@ -2,46 +2,14 @@
#define ASSET_INVALID 0xFF
#define _ASSETS\
X(ASSET_EMPTY)\
X(ASSET_BLANK)\
X(ASSET_BLOCK_FRAME)\
X(ASSET_BUILDMODE_HIGHLIGHT)\
X(ASSET_PLAYER)\
X(ASSET_THING)\
X(ASSET_CHEST)\
X(ASSET_FURNACE)\
X(ASSET_BLUEPRINT_BEGIN)\
X(ASSET_BLUEPRINT)\
X(ASSET_BLUEPRINT_DEMO_HOUSE)\
X(ASSET_BLUEPRINT_END)\
X(ASSET_FENCE)\
X(ASSET_DEV)\
X(ASSET_GROUND)\
X(ASSET_DIRT)\
X(ASSET_WATER)\
X(ASSET_LAVA)\
X(ASSET_WALL)\
X(ASSET_HILL)\
X(ASSET_HILL_SNOW)\
X(ASSET_HOLE)\
X(ASSET_WOOD)\
X(ASSET_TREE)\
X(ASSET_COAL)\
X(ASSET_IRON_ORE)\
X(ASSET_IRON_INGOT)\
X(ASSET_TEST_TALL)\
X(ASSET_BELT)\
X(ASSET_BELT_LEFT)\
X(ASSET_BELT_RIGHT)\
X(ASSET_BELT_UP)\
X(ASSET_BELT_DOWN)\
#include "assets_ids.lst"
typedef enum {
#define X(id) id,
#define X(idx) idx,
_ASSETS
#undef X
MAX_ASSETS,
MAX_ASSETS
} asset_id;
extern const char *asset_names[];

View File

@ -0,0 +1,36 @@
#define _ASSETS\
X(ASSET_EMPTY)\
X(ASSET_BLANK)\
X(ASSET_BLOCK_FRAME)\
X(ASSET_BUILDMODE_HIGHLIGHT)\
X(ASSET_PLAYER)\
X(ASSET_THING)\
X(ASSET_CHEST)\
X(ASSET_FURNACE)\
X(ASSET_CRAFTBENCH)\
X(ASSET_BLUEPRINT_BEGIN)\
X(ASSET_BLUEPRINT)\
X(ASSET_BLUEPRINT_DEMO_HOUSE)\
X(ASSET_BLUEPRINT_END)\
X(ASSET_FENCE)\
X(ASSET_DEV)\
X(ASSET_GROUND)\
X(ASSET_DIRT)\
X(ASSET_WATER)\
X(ASSET_LAVA)\
X(ASSET_WALL)\
X(ASSET_HILL)\
X(ASSET_HILL_SNOW)\
X(ASSET_HOLE)\
X(ASSET_WOOD)\
X(ASSET_TREE)\
X(ASSET_COAL)\
X(ASSET_IRON_ORE)\
X(ASSET_IRON_INGOT)\
X(ASSET_TEST_TALL)\
X(ASSET_BELT)\
X(ASSET_BELT_LEFT)\
X(ASSET_BELT_RIGHT)\
X(ASSET_BELT_UP)\
X(ASSET_BELT_DOWN)

View File

@ -18,6 +18,7 @@ static asset assets[] = {
ASSET_TEX(ASSET_COAL),
ASSET_TEX(ASSET_CHEST),
ASSET_TEX(ASSET_FURNACE),
ASSET_TEX(ASSET_CRAFTBENCH),
ASSET_TEX(ASSET_BLUEPRINT),
ASSET_TEX(ASSET_BLUEPRINT_DEMO_HOUSE),

View File

@ -2,6 +2,7 @@
#include "models/prefabs/storage.h"
#include "models/prefabs/furnace.h"
#include "models/prefabs/blueprint.h"
#include "models/prefabs/craftbench.h"
static struct {
asset_id id;
@ -10,6 +11,7 @@ static struct {
} entity_spawnlist[] = {
{ .id = ASSET_CHEST, .proc = storage_spawn },
{ .id = ASSET_FURNACE, .proc = furnace_spawn },
{ .id = ASSET_CRAFTBENCH, .proc = craftbench_spawn },
{ .id = ASSET_BLUEPRINT, .proc_udata = blueprint_spawn_udata },
};

View File

@ -23,5 +23,6 @@ static item_desc items[] = {
ITEM_PROXY(ASSET_BELT_DOWN, ASSET_BELT),
ITEM_ENT(ASSET_CHEST, 32, ASSET_CHEST),
ITEM_ENT(ASSET_CRAFTBENCH, 32, ASSET_CRAFTBENCH),
ITEM_ENT(ASSET_FURNACE, 32, ASSET_FURNACE),
};

View File

@ -0,0 +1,24 @@
#include "craftbench.h"
#include "models/device.h"
#include "world/world.h"
#include "models/entity.h"
#include "models/components.h"
uint64_t craftbench_spawn(void) {
ecs_entity_t e = device_spawn(ASSET_CRAFTBENCH);
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
*storage = (ItemContainer){0};
Producer *producer = ecs_get_mut(world_ecs(), e, Producer);
*producer = (Producer){0};
producer->energy_level = 69.0f;
ecs_set(world_ecs(), e, ItemRouter, {1});
return (uint64_t)e;
}
void craftbench_despawn(uint64_t ent_id) {
entity_despawn(ent_id);
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "platform/system.h"
uint64_t craftbench_spawn(void);
void craftbench_despawn(uint64_t id);

View File

@ -17,6 +17,7 @@ patterns =
"*.txt",
"*.cmake",
"*.md",
"*.lst",
};
blacklist_patterns =