improve blueprints

efd/v1
Dominik Madarász 2022-10-16 13:00:50 +02:00
parent 71dc349e4e
commit 93612f5462
9 changed files with 78 additions and 150 deletions

View File

@ -12,9 +12,6 @@ typedef enum {
RPKIND_PLACE_ICE_RINK, RPKIND_PLACE_ICE_RINK,
RPKIND_PLACE_ERASE_CHANGES, RPKIND_PLACE_ERASE_CHANGES,
RPKIND_SPAWN_CIRCLING_DRIVER, RPKIND_SPAWN_CIRCLING_DRIVER,
RPKIND_SPAWN_ICEMAKER_ITEM,
RPKIND_SPAWN_CHEST,
RPKIND_SPAWN_BELT,
} replay_kind; } replay_kind;
typedef struct { typedef struct {
@ -225,15 +222,6 @@ void debug_replay_update(void) {
case RPKIND_PLACE_ERASE_CHANGES:{ case RPKIND_PLACE_ERASE_CHANGES:{
ActEraseWorldChanges(); ActEraseWorldChanges();
}break; }break;
case RPKIND_SPAWN_ICEMAKER_ITEM:{
ActSpawnCoal();
}break;
case RPKIND_SPAWN_CHEST:{
ActSpawnChest();
}break;
case RPKIND_SPAWN_BELT:{
ActSpawnBelt();
}break;
default: { default: {
ZPL_PANIC("unreachable"); ZPL_PANIC("unreachable");
}break; }break;

View File

@ -21,92 +21,6 @@ ActSpawnCar(void) {
debug_replay_special_action(RPKIND_SPAWN_CAR); debug_replay_special_action(RPKIND_SPAWN_CAR);
} }
void
ActSpawnCoal(void) {
ecs_entity_t e = item_spawn(ASSET_COAL, 32);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
debug_replay_special_action(RPKIND_SPAWN_ICEMAKER_ITEM);
}
void
ActSpawnChest(void) {
ecs_entity_t e = item_spawn(ASSET_CHEST, 32);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
debug_replay_special_action(RPKIND_SPAWN_CHEST);
}
void
ActSpawnBelt(void) {
ecs_entity_t e = item_spawn(ASSET_BELT, 32);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
debug_replay_special_action(RPKIND_SPAWN_BELT);
}
void
ActSpawnDurabilityTest(void) {
ecs_entity_t e = item_spawn(ASSET_COAL, 1);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
Item *it = ecs_get_mut(world_ecs(), e, Item);
it->durability = (float)(rand() % 100) / 100.0f;
}
void
ActSpawnFurnace(void) {
ecs_entity_t e = item_spawn(ASSET_FURNACE, 32);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
}
void
ActSpawnTallTest(void) {
ecs_entity_t e = item_spawn(ASSET_TEST_TALL, 32);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
}
void
ActSpawnDemoHouseItem(void) {
ecs_entity_t e = item_spawn(ASSET_BLUEPRINT, 1);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
}
void void
ActSpawnItemPrev(void) { ActSpawnItemPrev(void) {
while (true) { while (true) {

View File

@ -17,6 +17,11 @@ Texture2D texgen_build_anim_fallback(asset_id id, int64_t counter) {
} }
Texture2D texgen_build_sprite_fallback(asset_id id) { Texture2D texgen_build_sprite_fallback(asset_id id) {
if (id > ASSET_BLUEPRINT_BEGIN && id < ASSET_BLUEPRINT_END) {
return LoadTexEco("blueprint");
}
switch (id) { switch (id) {
case ASSET_BLANK: return GenColorEco(WHITE); break; case ASSET_BLANK: return GenColorEco(WHITE); break;
case ASSET_BUILDMODE_HIGHLIGHT: return GenColorEco(WHITE); break; case ASSET_BUILDMODE_HIGHLIGHT: return GenColorEco(WHITE); break;
@ -24,7 +29,6 @@ Texture2D texgen_build_sprite_fallback(asset_id id) {
// NOTE(zaklaus): items // NOTE(zaklaus): items
case ASSET_COAL: return LoadTexEco("coal"); case ASSET_COAL: return LoadTexEco("coal");
case ASSET_BLUEPRINT: return LoadTexEco("blueprint");
// NOTE(zaklaus): blocks // NOTE(zaklaus): blocks
case ASSET_FENCE: return LoadTexEco("fence"); case ASSET_FENCE: return LoadTexEco("fence");

View File

@ -11,7 +11,10 @@
X(ASSET_THING)\ X(ASSET_THING)\
X(ASSET_CHEST)\ X(ASSET_CHEST)\
X(ASSET_FURNACE)\ X(ASSET_FURNACE)\
X(ASSET_BLUEPRINT_BEGIN)\
X(ASSET_BLUEPRINT)\ X(ASSET_BLUEPRINT)\
X(ASSET_BLUEPRINT_DEMO_HOUSE)\
X(ASSET_BLUEPRINT_END)\
X(ASSET_FENCE)\ X(ASSET_FENCE)\
X(ASSET_DEV)\ X(ASSET_DEV)\
X(ASSET_GROUND)\ X(ASSET_GROUND)\
@ -38,7 +41,7 @@ typedef enum {
#define X(id) id, #define X(id) id,
_ASSETS _ASSETS
#undef X #undef X
MAX_ASSETS = 1024, MAX_ASSETS,
} asset_id; } asset_id;
extern const char *asset_names[]; extern const char *asset_names[];

View File

@ -19,6 +19,7 @@ static asset assets[] = {
ASSET_TEX(ASSET_CHEST), ASSET_TEX(ASSET_CHEST),
ASSET_TEX(ASSET_FURNACE), ASSET_TEX(ASSET_FURNACE),
ASSET_TEX(ASSET_BLUEPRINT), ASSET_TEX(ASSET_BLUEPRINT),
ASSET_TEX(ASSET_BLUEPRINT_DEMO_HOUSE),
// NOTE(zaklaus): blocks // NOTE(zaklaus): blocks
ASSET_TEX(ASSET_FENCE), ASSET_TEX(ASSET_FENCE),

View File

@ -11,7 +11,7 @@ static item_desc items[] = {
ITEM_SELF(ASSET_TEST_TALL, 64), ITEM_SELF(ASSET_TEST_TALL, 64),
// ITEM_BLUEPRINT(ASSET_BLUEPRINT, 1, 4, 4, "]]]]]CF] ]]]]]"), // ITEM_BLUEPRINT(ASSET_BLUEPRINT, 1, 4, 4, "]]]]]CF] ]]]]]"),
ITEM_BLUEPRINT(ASSET_BLUEPRINT, 1, 4, 4, PROT({ ASSET_WOOD,ASSET_WOOD,ASSET_WOOD,ASSET_WOOD, ITEM_BLUEPRINT_PROXY(ASSET_BLUEPRINT_DEMO_HOUSE, ASSET_BLUEPRINT, 1, 4, 4, PROT({ ASSET_WOOD,ASSET_WOOD,ASSET_WOOD,ASSET_WOOD,
ASSET_WOOD,ASSET_FURNACE,ASSET_CHEST,ASSET_WOOD, ASSET_WOOD,ASSET_FURNACE,ASSET_CHEST,ASSET_WOOD,
ASSET_FENCE,ASSET_EMPTY,ASSET_EMPTY,ASSET_WOOD, ASSET_FENCE,ASSET_EMPTY,ASSET_EMPTY,ASSET_WOOD,
ASSET_WALL,ASSET_EMPTY,ASSET_EMPTY,ASSET_WOOD})), ASSET_WALL,ASSET_EMPTY,ASSET_EMPTY,ASSET_WOOD})),

View File

@ -39,6 +39,23 @@ __VA_ARGS__\
__VA_ARGS__\ __VA_ARGS__\
} }
#define ITEM_BLUEPRINT_PROXY(asset, place_asset, qty, w_, h_, plan_, ...)\
{\
.kind = asset,\
.usage = UKIND_PLACE_ITEM_DATA,\
.attachment = UDATA_NONE,\
.max_quantity = qty,\
.blueprint = {\
.w = w_,\
.h = h_,\
.plan = (const asset_id[])plan_\
},\
.place_item = {\
.id = place_asset\
},\
__VA_ARGS__\
}
#define ITEM_INGREDIENT(asset, qty, _producer, _product, _additional, ...)\ #define ITEM_INGREDIENT(asset, qty, _producer, _product, _additional, ...)\
{\ {\
.kind = asset,\ .kind = asset,\

View File

@ -20,6 +20,7 @@ uint16_t assets_find(asset_id id);
asset_kind assets_get_kind(uint16_t id); asset_kind assets_get_kind(uint16_t id);
void *assets_get_snd(uint16_t id); void *assets_get_snd(uint16_t id);
void *assets_get_tex(uint16_t id); void *assets_get_tex(uint16_t id);
uint16_t assets_resolve_proxy(uint16_t id);
// NOTE(zaklaus): client only // NOTE(zaklaus): client only
#define ASSET_SRC_RECT() ((Rectangle){0, 0, 64, 64}) #define ASSET_SRC_RECT() ((Rectangle){0, 0, 64, 64})