make prefabs folder
parent
914b72c44f
commit
8e013c4171
|
@ -10,11 +10,12 @@ add_library(eco2d-foundation STATIC
|
||||||
|
|
||||||
src/ents/items.c
|
src/ents/items.c
|
||||||
src/ents/entity.c
|
src/ents/entity.c
|
||||||
src/ents/player.c
|
|
||||||
src/ents/vehicle.c
|
|
||||||
src/ents/storage.c
|
|
||||||
src/ents/device.c
|
src/ents/device.c
|
||||||
src/ents/furnace.c
|
|
||||||
|
src/ents/prefabs/player.c
|
||||||
|
src/ents/prefabs/vehicle.c
|
||||||
|
src/ents/prefabs/storage.c
|
||||||
|
src/ents/prefabs/furnace.c
|
||||||
|
|
||||||
src/pkt/packet.c
|
src/pkt/packet.c
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "debug/debug_ui.h"
|
#include "debug/debug_ui.h"
|
||||||
#include "debug/debug_draw.h"
|
#include "debug/debug_draw.h"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "ents/vehicle.h"
|
#include "ents/prefabs/vehicle.h"
|
||||||
#include "core/camera.h"
|
#include "core/camera.h"
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
#include "core/game.h"
|
#include "core/game.h"
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
|
|
||||||
uint64_t device_spawn(asset_id id) {
|
uint64_t device_spawn(asset_id id) {
|
||||||
ecs_entity_t e = entity_spawn(EKIND_DEVICE);
|
ecs_entity_t e = entity_spawn(EKIND_DEVICE);
|
||||||
|
|
||||||
Device *dev = ecs_get_mut(world_ecs(), e, Device);
|
Device *dev = ecs_get_mut(world_ecs(), e, Device);
|
||||||
dev->asset = id;
|
dev->asset = id;
|
||||||
|
|
||||||
return (uint64_t)e;
|
return (uint64_t)e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
|
|
||||||
uint64_t entity_spawn(uint16_t class_id) {
|
uint64_t entity_spawn(uint16_t class_id) {
|
||||||
ecs_entity_t e = ecs_new(world_ecs(), 0);
|
ecs_entity_t e = ecs_new(world_ecs(), 0);
|
||||||
|
|
||||||
ecs_set(world_ecs(), e, Classify, { .id = class_id });
|
ecs_set(world_ecs(), e, Classify, { .id = class_id });
|
||||||
entity_wake(e);
|
entity_wake(e);
|
||||||
|
|
||||||
if (class_id != EKIND_SERVER) {
|
if (class_id != EKIND_SERVER) {
|
||||||
ecs_set(world_ecs(), e, Velocity, {0});
|
ecs_set(world_ecs(), e, Velocity, {0});
|
||||||
Position *pos = ecs_get_mut(world_ecs(), e, Position);
|
Position *pos = ecs_get_mut(world_ecs(), e, Position);
|
||||||
|
@ -28,12 +28,12 @@ uint64_t entity_spawn(uint16_t class_id) {
|
||||||
pos->x=350.0f;
|
pos->x=350.0f;
|
||||||
pos->y=88.0f;
|
pos->y=88.0f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
librg_entity_track(world_tracker(), e);
|
librg_entity_track(world_tracker(), e);
|
||||||
librg_entity_chunk_set(world_tracker(), e, librg_chunk_from_realpos(world_tracker(), pos->x, pos->y, 0));
|
librg_entity_chunk_set(world_tracker(), e, librg_chunk_from_realpos(world_tracker(), pos->x, pos->y, 0));
|
||||||
librg_entity_owner_set(world_tracker(), e, (int64_t)e);
|
librg_entity_owner_set(world_tracker(), e, (int64_t)e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint64_t)e;
|
return (uint64_t)e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +81,12 @@ void entity_update_action_timers() {
|
||||||
ecs_streaminfo = ecs_query_new(world_ecs(), "components.StreamInfo");
|
ecs_streaminfo = ecs_query_new(world_ecs(), "components.StreamInfo");
|
||||||
last_update_time = get_cached_time();
|
last_update_time = get_cached_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
ecs_iter_t it = ecs_query_iter(world_ecs(), ecs_streaminfo);
|
ecs_iter_t it = ecs_query_iter(world_ecs(), ecs_streaminfo);
|
||||||
|
|
||||||
while (ecs_query_next(&it)) {
|
while (ecs_query_next(&it)) {
|
||||||
StreamInfo *si = ecs_field(&it, StreamInfo, 1);
|
StreamInfo *si = ecs_field(&it, StreamInfo, 1);
|
||||||
|
|
||||||
for (int32_t i = 0; i < it.count; i++) {
|
for (int32_t i = 0; i < it.count; i++) {
|
||||||
if (si[i].last_update < get_cached_time()) {
|
if (si[i].last_update < get_cached_time()) {
|
||||||
si[i].last_update = get_cached_time() + si[i].tick_delay;
|
si[i].last_update = get_cached_time() + si[i].tick_delay;
|
||||||
|
@ -94,7 +94,7 @@ void entity_update_action_timers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last_update_time = get_cached_time();
|
last_update_time = get_cached_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// NOTE(zaklaus): access to spawners
|
// NOTE(zaklaus): access to spawners
|
||||||
#include "ents/storage.h"
|
#include "ents/prefabs/storage.h"
|
||||||
#include "ents/furnace.h"
|
#include "ents/prefabs/furnace.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
asset_id id;
|
asset_id id;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#include "ents/furnace.h"
|
#include "furnace.h"
|
||||||
#include "ents/device.h"
|
#include "ents/device.h"
|
||||||
#include "ents/entity.h"
|
|
||||||
#include "world/entity_view.h"
|
|
||||||
#include "world/world.h"
|
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
|
|
|
@ -1,31 +1,27 @@
|
||||||
#include "ents/player.h"
|
#include "player.h"
|
||||||
#include "ents/entity.h"
|
|
||||||
#include "world/entity_view.h"
|
#include "world/entity_view.h"
|
||||||
#include "flecs/flecs.h"
|
|
||||||
#include "librg.h"
|
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
#include "ecs/systems.h"
|
|
||||||
#include "zpl.h"
|
|
||||||
|
|
||||||
#define PLAYER_MAX_HP 100.0f
|
#define PLAYER_MAX_HP 100.0f
|
||||||
|
|
||||||
uint64_t player_spawn(char *name) {
|
uint64_t player_spawn(char *name) {
|
||||||
ecs_entity_t e = entity_spawn(EKIND_PLAYER);
|
ecs_entity_t e = entity_spawn(EKIND_PLAYER);
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = zpl_bprintf("player_%d", e);
|
name = zpl_bprintf("player_%d", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ecs_set_name(world_ecs(), e, name);
|
ecs_set_name(world_ecs(), e, name);
|
||||||
ecs_set(world_ecs(), e, ClientInfo, {0});
|
ecs_set(world_ecs(), e, ClientInfo, {0});
|
||||||
ecs_set(world_ecs(), e, Input, {0});
|
ecs_set(world_ecs(), e, Input, {0});
|
||||||
ecs_set(world_ecs(), e, Inventory, {0});
|
ecs_set(world_ecs(), e, Inventory, {0});
|
||||||
ecs_set(world_ecs(), e, Health, {.hp = PLAYER_MAX_HP, .max_hp = PLAYER_MAX_HP});
|
ecs_set(world_ecs(), e, Health, {.hp = PLAYER_MAX_HP, .max_hp = PLAYER_MAX_HP});
|
||||||
|
|
||||||
librg_entity_owner_set(world_tracker(), e, (int64_t)e);
|
librg_entity_owner_set(world_tracker(), e, (int64_t)e);
|
||||||
|
|
||||||
return (uint64_t)e;
|
return (uint64_t)e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
#include "ents/storage.h"
|
#include "storage.h"
|
||||||
#include "ents/device.h"
|
#include "ents/device.h"
|
||||||
#include "ents/entity.h"
|
|
||||||
#include "world/entity_view.h"
|
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
|
|
||||||
uint64_t storage_spawn(void) {
|
uint64_t storage_spawn(void) {
|
||||||
ecs_entity_t e = device_spawn(ASSET_CHEST);
|
ecs_entity_t e = device_spawn(ASSET_CHEST);
|
||||||
|
|
||||||
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
||||||
*storage = (ItemContainer){0};
|
*storage = (ItemContainer){0};
|
||||||
return (uint64_t)e;
|
return (uint64_t)e;
|
|
@ -1,5 +1,5 @@
|
||||||
#include "ents/vehicle.h"
|
#include "vehicle.h"
|
||||||
#include "ents/entity.h"
|
|
||||||
#include "world/entity_view.h"
|
#include "world/entity_view.h"
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
|
|
|
@ -21,3 +21,6 @@
|
||||||
// NOTE(zaklaus): Register an item
|
// NOTE(zaklaus): Register an item
|
||||||
#include "items_list.c"
|
#include "items_list.c"
|
||||||
|
|
||||||
|
// NOTE(zaklaus): Register a spawnable entity
|
||||||
|
#include "ents/entity_spawnlist.c"
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "packets/pkt_00_init.h"
|
#include "packets/pkt_00_init.h"
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
#include "core/game.h"
|
#include "core/game.h"
|
||||||
#include "ents/player.h"
|
#include "ents/prefabs/player.h"
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "net/network.h"
|
#include "net/network.h"
|
||||||
#include "world/entity_view.h"
|
#include "world/entity_view.h"
|
||||||
#include "core/camera.h"
|
#include "core/camera.h"
|
||||||
#include "ents/player.h"
|
#include "ents/prefabs/player.h"
|
||||||
#include "ents/entity.h"
|
#include "ents/entity.h"
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "net/network.h"
|
#include "net/network.h"
|
||||||
#include "world/entity_view.h"
|
#include "world/entity_view.h"
|
||||||
#include "core/camera.h"
|
#include "core/camera.h"
|
||||||
#include "ents/player.h"
|
#include "ents/prefabs/player.h"
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
#include "ecs/systems.h"
|
#include "ecs/systems.h"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
#include "ents/entity.h"
|
#include "ents/entity.h"
|
||||||
#include "ents/vehicle.h"
|
#include "ents/prefabs/vehicle.h"
|
||||||
#include "ents/items.h"
|
#include "ents/items.h"
|
||||||
#include "world/blocks_info.h"
|
#include "world/blocks_info.h"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "ecs/components.h"
|
#include "ecs/components.h"
|
||||||
#include "ents/entity.h"
|
#include "ents/entity.h"
|
||||||
#include "ents/vehicle.h"
|
#include "ents/prefabs/vehicle.h"
|
||||||
#include "ents/items.h"
|
#include "ents/items.h"
|
||||||
#include "world/blocks_info.h"
|
#include "world/blocks_info.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue