add more vehicle types
parent
11929260e2
commit
ed5fd927ab
|
@ -208,7 +208,7 @@ void debug_replay_update(void) {
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case RPKIND_SPAWN_CAR: {
|
case RPKIND_SPAWN_CAR: {
|
||||||
ecs_entity_t e = vehicle_spawn();
|
ecs_entity_t e = vehicle_spawn(EVEH_CAR);
|
||||||
|
|
||||||
Position const *origin = ecs_get(world_ecs(), mime, Position);
|
Position const *origin = ecs_get(world_ecs(), mime, Position);
|
||||||
Position *dest = ecs_get_mut(world_ecs(), e, Position);
|
Position *dest = ecs_get_mut(world_ecs(), e, Position);
|
||||||
|
|
|
@ -10,7 +10,7 @@ ActExitGame(void) {
|
||||||
|
|
||||||
void
|
void
|
||||||
ActSpawnCar(void) {
|
ActSpawnCar(void) {
|
||||||
ecs_entity_t e = vehicle_spawn();
|
ecs_entity_t e = vehicle_spawn(EVEH_CAR);
|
||||||
ecs_entity_t plr = camera_get().ent_id;
|
ecs_entity_t plr = camera_get().ent_id;
|
||||||
|
|
||||||
Position const* origin = ecs_get(world_ecs(), plr, Position);
|
Position const* origin = ecs_get(world_ecs(), plr, Position);
|
||||||
|
@ -74,7 +74,7 @@ ActSpawnFurnace(void) {
|
||||||
void
|
void
|
||||||
ActSpawnCirclingDriver(void) {
|
ActSpawnCirclingDriver(void) {
|
||||||
ecs_entity_t plr = camera_get().ent_id;
|
ecs_entity_t plr = camera_get().ent_id;
|
||||||
ecs_entity_t ve = vehicle_spawn();
|
ecs_entity_t ve = vehicle_spawn(EVEH_CAR);
|
||||||
ecs_entity_t e = entity_spawn(EKIND_DEMO_NPC);
|
ecs_entity_t e = entity_spawn(EKIND_DEMO_NPC);
|
||||||
|
|
||||||
Position const *origin = ecs_get(world_ecs(), plr, Position);
|
Position const *origin = ecs_get(world_ecs(), plr, Position);
|
||||||
|
|
|
@ -12,11 +12,11 @@ ECS_COMPONENT_DECLARE(Classify);
|
||||||
ECS_COMPONENT_DECLARE(Vehicle);
|
ECS_COMPONENT_DECLARE(Vehicle);
|
||||||
ECS_COMPONENT_DECLARE(IsInVehicle);
|
ECS_COMPONENT_DECLARE(IsInVehicle);
|
||||||
ECS_COMPONENT_DECLARE(Item);
|
ECS_COMPONENT_DECLARE(Item);
|
||||||
ECS_COMPONENT_DECLARE(ItemAlreadyEdited);
|
ECS_COMPONENT_DECLARE(BlockHarvest);
|
||||||
ECS_COMPONENT_DECLARE(Inventory);
|
ECS_COMPONENT_DECLARE(Inventory);
|
||||||
ECS_COMPONENT_DECLARE(ItemContainer);
|
ECS_COMPONENT_DECLARE(ItemContainer);
|
||||||
ECS_COMPONENT_DECLARE(Furnace);
|
ECS_COMPONENT_DECLARE(Producer);
|
||||||
ECS_COMPONENT_DECLARE(Fuel);
|
ECS_COMPONENT_DECLARE(EnergySource);
|
||||||
ECS_COMPONENT_DECLARE(Ingredient);
|
ECS_COMPONENT_DECLARE(Ingredient);
|
||||||
ECS_COMPONENT_DECLARE(Device);
|
ECS_COMPONENT_DECLARE(Device);
|
||||||
ECS_COMPONENT_DECLARE(DemoNPC);
|
ECS_COMPONENT_DECLARE(DemoNPC);
|
||||||
|
@ -37,11 +37,11 @@ void ComponentsImport(ecs_world_t *ecs) {
|
||||||
ECS_COMPONENT_DEFINE(ecs, Vehicle);
|
ECS_COMPONENT_DEFINE(ecs, Vehicle);
|
||||||
ECS_COMPONENT_DEFINE(ecs, IsInVehicle);
|
ECS_COMPONENT_DEFINE(ecs, IsInVehicle);
|
||||||
ECS_COMPONENT_DEFINE(ecs, Item);
|
ECS_COMPONENT_DEFINE(ecs, Item);
|
||||||
ECS_COMPONENT_DEFINE(ecs, ItemAlreadyEdited);
|
ECS_COMPONENT_DEFINE(ecs, BlockHarvest);
|
||||||
ECS_COMPONENT_DEFINE(ecs, Inventory);
|
ECS_COMPONENT_DEFINE(ecs, Inventory);
|
||||||
ECS_COMPONENT_DEFINE(ecs, ItemContainer);
|
ECS_COMPONENT_DEFINE(ecs, ItemContainer);
|
||||||
ECS_COMPONENT_DEFINE(ecs, Furnace);
|
ECS_COMPONENT_DEFINE(ecs, Producer);
|
||||||
ECS_COMPONENT_DEFINE(ecs, Fuel);
|
ECS_COMPONENT_DEFINE(ecs, EnergySource);
|
||||||
ECS_COMPONENT_DEFINE(ecs, Ingredient);
|
ECS_COMPONENT_DEFINE(ecs, Ingredient);
|
||||||
ECS_COMPONENT_DEFINE(ecs, Device);
|
ECS_COMPONENT_DEFINE(ecs, Device);
|
||||||
ECS_COMPONENT_DEFINE(ecs, DemoNPC);
|
ECS_COMPONENT_DEFINE(ecs, DemoNPC);
|
||||||
|
|
|
@ -100,6 +100,7 @@ typedef struct {
|
||||||
|
|
||||||
float speed;
|
float speed;
|
||||||
float reverse_speed;
|
float reverse_speed;
|
||||||
|
uint8_t veh_kind;
|
||||||
} Vehicle;
|
} Vehicle;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -115,7 +116,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char _unused;
|
char _unused;
|
||||||
} ItemAlreadyEdited;
|
} BlockHarvest;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// TODO: we now hold a ref to an item, instead of representing an item slot,
|
// TODO: we now hold a ref to an item, instead of representing an item slot,
|
||||||
|
@ -130,14 +131,14 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
asset_id processed_item;
|
asset_id processed_item;
|
||||||
float cook_time;
|
float process_time;
|
||||||
float burn_time;
|
float energy_level;
|
||||||
} Furnace;
|
} Producer;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
asset_id kind;
|
asset_id kind;
|
||||||
float burn_time;
|
float energy_level;
|
||||||
} Fuel;
|
} EnergySource;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
asset_id producer;
|
asset_id producer;
|
||||||
|
@ -168,11 +169,11 @@ extern ECS_COMPONENT_DECLARE(Classify);
|
||||||
extern ECS_COMPONENT_DECLARE(Vehicle);
|
extern ECS_COMPONENT_DECLARE(Vehicle);
|
||||||
extern ECS_COMPONENT_DECLARE(IsInVehicle);
|
extern ECS_COMPONENT_DECLARE(IsInVehicle);
|
||||||
extern ECS_COMPONENT_DECLARE(Item);
|
extern ECS_COMPONENT_DECLARE(Item);
|
||||||
extern ECS_COMPONENT_DECLARE(ItemAlreadyEdited);
|
extern ECS_COMPONENT_DECLARE(BlockHarvest);
|
||||||
extern ECS_COMPONENT_DECLARE(Inventory);
|
extern ECS_COMPONENT_DECLARE(Inventory);
|
||||||
extern ECS_COMPONENT_DECLARE(ItemContainer);
|
extern ECS_COMPONENT_DECLARE(ItemContainer);
|
||||||
extern ECS_COMPONENT_DECLARE(Furnace);
|
extern ECS_COMPONENT_DECLARE(Producer);
|
||||||
extern ECS_COMPONENT_DECLARE(Fuel);
|
extern ECS_COMPONENT_DECLARE(EnergySource);
|
||||||
extern ECS_COMPONENT_DECLARE(Ingredient);
|
extern ECS_COMPONENT_DECLARE(Ingredient);
|
||||||
extern ECS_COMPONENT_DECLARE(Device);
|
extern ECS_COMPONENT_DECLARE(Device);
|
||||||
extern ECS_COMPONENT_DECLARE(DemoNPC);
|
extern ECS_COMPONENT_DECLARE(DemoNPC);
|
||||||
|
|
|
@ -44,9 +44,12 @@ uint64_t item_spawn(asset_id kind, uint32_t qty) {
|
||||||
item_desc *it = &items[item_find(kind)];
|
item_desc *it = &items[item_find(kind)];
|
||||||
|
|
||||||
switch (it->attachment) {
|
switch (it->attachment) {
|
||||||
case UDATA_FUEL: {
|
case UDATA_ENERGY_SOURCE: {
|
||||||
Fuel *f = ecs_get_mut(world_ecs(), e, Fuel);
|
EnergySource *f = ecs_get_mut(world_ecs(), e, EnergySource);
|
||||||
f->burn_time = it->fuel.burn_time;
|
*f = (EnergySource){
|
||||||
|
.kind = it->energy_source.producer,
|
||||||
|
.energy_level = it->energy_source.energy_level,
|
||||||
|
};
|
||||||
} break;
|
} break;
|
||||||
case UDATA_INGREDIENT: {
|
case UDATA_INGREDIENT: {
|
||||||
Ingredient *i = ecs_get_mut(world_ecs(), e, Ingredient);
|
Ingredient *i = ecs_get_mut(world_ecs(), e, Ingredient);
|
||||||
|
|
|
@ -19,7 +19,7 @@ typedef enum {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UDATA_NONE,
|
UDATA_NONE,
|
||||||
UDATA_FUEL,
|
UDATA_ENERGY_SOURCE,
|
||||||
UDATA_INGREDIENT,
|
UDATA_INGREDIENT,
|
||||||
} item_attachment;
|
} item_attachment;
|
||||||
|
|
||||||
|
@ -47,8 +47,9 @@ typedef struct {
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
float burn_time;
|
asset_id producer;
|
||||||
} fuel;
|
float energy_level;
|
||||||
|
} energy_source;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
asset_id producer;
|
asset_id producer;
|
||||||
|
|
|
@ -6,7 +6,7 @@ static item_desc items[] = {
|
||||||
{ .kind = 0, .max_quantity = 0, },
|
{ .kind = 0, .max_quantity = 0, },
|
||||||
ITEM_INGREDIENT(ASSET_DEMO_ICEMAKER, 64, ASSET_FURNACE, ASSET_BELT, 0),
|
ITEM_INGREDIENT(ASSET_DEMO_ICEMAKER, 64, ASSET_FURNACE, ASSET_BELT, 0),
|
||||||
ITEM_SELF(ASSET_FENCE, 64),
|
ITEM_SELF(ASSET_FENCE, 64),
|
||||||
ITEM_FUEL(ASSET_WOOD, 64, 15.0f),
|
ITEM_ENERGY(ASSET_WOOD, ASSET_FURNACE, 64, 15.0f),
|
||||||
ITEM_HOLD(ASSET_TREE, 64),
|
ITEM_HOLD(ASSET_TREE, 64),
|
||||||
|
|
||||||
ITEM_SELF_DIR(ASSET_BELT, 999),
|
ITEM_SELF_DIR(ASSET_BELT, 999),
|
||||||
|
|
|
@ -8,14 +8,15 @@
|
||||||
.max_quantity = qty,\
|
.max_quantity = qty,\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ITEM_FUEL(asset, qty, fuel_value)\
|
#define ITEM_ENERGY(asset, producer_asset, qty, energy_value)\
|
||||||
{\
|
{\
|
||||||
.kind = asset,\
|
.kind = asset,\
|
||||||
.usage = UKIND_HOLD,\
|
.usage = UKIND_HOLD,\
|
||||||
.attachment = UDATA_FUEL,\
|
.attachment = UDATA_ENERGY_SOURCE,\
|
||||||
.max_quantity = qty,\
|
.max_quantity = qty,\
|
||||||
.fuel = {\
|
.energy_source = {\
|
||||||
.burn_time = fuel_value\
|
.producer = producer_asset,\
|
||||||
|
.energy_level = energy_value\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ uint64_t furnace_spawn(void) {
|
||||||
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
||||||
*storage = (ItemContainer){0};
|
*storage = (ItemContainer){0};
|
||||||
|
|
||||||
Furnace *furnace = ecs_get_mut(world_ecs(), e, Furnace);
|
Producer *producer = ecs_get_mut(world_ecs(), e, Producer);
|
||||||
*furnace = (Furnace){0};
|
*producer = (Producer){0};
|
||||||
furnace->burn_time = 69.0f;
|
producer->energy_level = 69.0f;
|
||||||
return (uint64_t)e;
|
return (uint64_t)e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
#include "models/entity.h"
|
#include "models/entity.h"
|
||||||
#include "models/components.h"
|
#include "models/components.h"
|
||||||
|
|
||||||
uint64_t vehicle_spawn(void) {
|
|
||||||
|
uint64_t vehicle_spawn(uint8_t veh_kind) {
|
||||||
ecs_entity_t e = entity_spawn(EKIND_VEHICLE);
|
ecs_entity_t e = entity_spawn(EKIND_VEHICLE);
|
||||||
|
|
||||||
Vehicle *veh = ecs_get_mut(world_ecs(), e, Vehicle);
|
Vehicle *veh = ecs_get_mut(world_ecs(), e, Vehicle);
|
||||||
|
@ -15,7 +16,47 @@ uint64_t vehicle_spawn(void) {
|
||||||
.speed = 50.0f,
|
.speed = 50.0f,
|
||||||
.reverse_speed = -20.0f,
|
.reverse_speed = -20.0f,
|
||||||
.force = 0.0f,
|
.force = 0.0f,
|
||||||
|
.veh_kind = veh_kind,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
switch (veh_kind) {
|
||||||
|
case EVEH_CAR: {
|
||||||
|
veh->wheel_base = 50.0f;
|
||||||
|
veh->speed = 50.0f;
|
||||||
|
veh->reverse_speed = -20.0f;
|
||||||
|
veh->force = 0.0f;
|
||||||
|
} break;
|
||||||
|
case EVEH_TRUCK: {
|
||||||
|
veh->wheel_base = 100.0f;
|
||||||
|
veh->speed = 30.0f;
|
||||||
|
veh->reverse_speed = -10.0f;
|
||||||
|
veh->force = 0.0f;
|
||||||
|
|
||||||
|
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
||||||
|
*storage = (ItemContainer){0};
|
||||||
|
|
||||||
|
Device *dev = ecs_get_mut(world_ecs(), e, Device);
|
||||||
|
dev->asset = ASSET_FURNACE;
|
||||||
|
} break;
|
||||||
|
case EVEH_FURNACEMOBILE: {
|
||||||
|
veh->wheel_base = 100.0f;
|
||||||
|
veh->speed = 30.0f;
|
||||||
|
veh->reverse_speed = -10.0f;
|
||||||
|
veh->force = 0.0f;
|
||||||
|
|
||||||
|
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
||||||
|
*storage = (ItemContainer){0};
|
||||||
|
|
||||||
|
Device *dev = ecs_get_mut(world_ecs(), e, Device);
|
||||||
|
dev->asset = ASSET_FURNACE;
|
||||||
|
|
||||||
|
Producer *producer = ecs_get_mut(world_ecs(), e, Producer);
|
||||||
|
*producer = (Producer){0};
|
||||||
|
producer->energy_level = 69.0f;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ecs_add(world_ecs(), e, BlockHarvest);
|
||||||
return (uint64_t)e;
|
return (uint64_t)e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "platform/system.h"
|
#include "platform/system.h"
|
||||||
|
|
||||||
uint64_t vehicle_spawn(void);
|
enum {
|
||||||
|
EVEH_CAR,
|
||||||
|
EVEH_TRUCK,
|
||||||
|
EVEH_FURNACEMOBILE,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint64_t vehicle_spawn(uint8_t veh_kind);
|
||||||
void vehicle_despawn(uint64_t id);
|
void vehicle_despawn(uint64_t id);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
void FurnaceCook(ecs_iter_t *it) {
|
void ProduceItems(ecs_iter_t *it) {
|
||||||
ItemContainer *storage = ecs_field(it, ItemContainer, 1);
|
ItemContainer *storage = ecs_field(it, ItemContainer, 1);
|
||||||
Furnace *furnace = ecs_field(it, Furnace, 2);
|
Producer *producer = ecs_field(it, Producer, 2);
|
||||||
Position *p = ecs_field(it, Position, 3);
|
Position *p = ecs_field(it, Position, 3);
|
||||||
Device *d = ecs_field(it, Device, 4);
|
Device *d = ecs_field(it, Device, 4);
|
||||||
|
|
||||||
|
@ -9,29 +9,28 @@ void FurnaceCook(ecs_iter_t *it) {
|
||||||
ecs_entity_t item_slot_ent = storage[i].items[j];
|
ecs_entity_t item_slot_ent = storage[i].items[j];
|
||||||
Item *item = item_get_data(item_slot_ent);
|
Item *item = item_get_data(item_slot_ent);
|
||||||
|
|
||||||
const Fuel *fuel = 0;
|
const EnergySource *energy_source = 0;
|
||||||
if ((fuel = ecs_get_if(it->world, item_slot_ent, Fuel))) {
|
if ((energy_source = ecs_get_if(it->world, item_slot_ent, EnergySource))) {
|
||||||
if (fuel->kind == d->asset) {
|
if (energy_source->kind == d->asset) {
|
||||||
furnace[i].burn_time += fuel->kind;
|
producer[i].energy_level += energy_source->kind;
|
||||||
item_despawn(item_slot_ent);
|
item_despawn(item_slot_ent);
|
||||||
storage[i].items[j] = 0;
|
storage[i].items[j] = 0;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (furnace[i].burn_time <= 0.0f) continue; TODO
|
// if (producer[i].burn_time <= 0.0f) continue; TODO
|
||||||
if (furnace[i].cook_time < game_time()) {
|
if (producer[i].process_time < game_time()) {
|
||||||
if (furnace[i].processed_item > 0) {
|
if (producer[i].processed_item > 0) {
|
||||||
uint64_t e = item_spawn(furnace[i].processed_item, 1);
|
uint64_t e = item_spawn(producer[i].processed_item, 1);
|
||||||
entity_set_position(e, p[i].x, p[i].y);
|
entity_set_position(e, p[i].x, p[i].y);
|
||||||
furnace[i].processed_item = 0;
|
producer[i].processed_item = 0;
|
||||||
} else {
|
} else {
|
||||||
const Ingredient *ing = 0;
|
const Ingredient *ing = 0;
|
||||||
if ((ing = ecs_get_if(it->world, item_slot_ent, Ingredient))) {
|
if ((ing = ecs_get_if(it->world, item_slot_ent, Ingredient))) {
|
||||||
if (ing->producer == d->asset) {
|
if (ing->producer == d->asset) {
|
||||||
furnace[i].processed_item = ing->product;
|
producer[i].processed_item = ing->product;
|
||||||
furnace[i].cook_time = game_time() + game_rules.furnace_cook_time;
|
producer[i].process_time = game_time() + game_rules.furnace_cook_time;
|
||||||
zpl_printf("e_id %llu, qty: %d\n", item_slot_ent, item->quantity);
|
|
||||||
item->quantity--;
|
item->quantity--;
|
||||||
if (item->quantity <= 0) {
|
if (item->quantity <= 0) {
|
||||||
item_despawn(item_slot_ent);
|
item_despawn(item_slot_ent);
|
|
@ -16,7 +16,7 @@
|
||||||
#include "modules/system_demo.c"
|
#include "modules/system_demo.c"
|
||||||
#include "modules/system_vehicle.c"
|
#include "modules/system_vehicle.c"
|
||||||
#include "modules/system_items.c"
|
#include "modules/system_items.c"
|
||||||
#include "modules/system_furnace.c"
|
#include "modules/system_producer.c"
|
||||||
|
|
||||||
static inline float physics_correction(float x, float vx, float bounce) {
|
static inline float physics_correction(float x, float vx, float bounce) {
|
||||||
float r = (((zpl_max(0.0f, (WORLD_BLOCK_SIZE/2.0f) - zpl_abs(x))*zpl_sign(x)))*(WORLD_BLOCK_SIZE/2.0f));
|
float r = (((zpl_max(0.0f, (WORLD_BLOCK_SIZE/2.0f) - zpl_abs(x))*zpl_sign(x)))*(WORLD_BLOCK_SIZE/2.0f));
|
||||||
|
@ -217,8 +217,8 @@ void SystemsImport(ecs_world_t *ecs) {
|
||||||
//ECS_SYSTEM(ecs, MergeItems, EcsPostUpdate, components.Position, components.ItemDrop);
|
//ECS_SYSTEM(ecs, MergeItems, EcsPostUpdate, components.Position, components.ItemDrop);
|
||||||
ECS_SYSTEM(ecs, UseItem, EcsPostUpdate, components.Input, components.Position, components.Inventory, !components.IsInVehicle);
|
ECS_SYSTEM(ecs, UseItem, EcsPostUpdate, components.Input, components.Position, components.Inventory, !components.IsInVehicle);
|
||||||
ECS_SYSTEM(ecs, InspectContainers, EcsPostUpdate, components.Input, !components.IsInVehicle);
|
ECS_SYSTEM(ecs, InspectContainers, EcsPostUpdate, components.Input, !components.IsInVehicle);
|
||||||
ECS_SYSTEM(ecs, HarvestIntoContainers, EcsPostUpdate, components.ItemContainer, components.Position);
|
ECS_SYSTEM(ecs, HarvestIntoContainers, EcsPostUpdate, components.ItemContainer, components.Position, [none] !components.BlockHarvest);
|
||||||
ECS_SYSTEM(ecs, FurnaceCook, EcsPostUpdate, components.ItemContainer, components.Furnace, components.Position, components.Device);
|
ECS_SYSTEM(ecs, ProduceItems, EcsPostUpdate, components.ItemContainer, components.Producer, components.Position, components.Device);
|
||||||
|
|
||||||
ECS_SYSTEM(ecs, ResetActivators, EcsPostUpdate, components.Input);
|
ECS_SYSTEM(ecs, ResetActivators, EcsPostUpdate, components.Input);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ pkt_desc pkt_entity_view_desc[] = {
|
||||||
{ PKT_KEEP_IF(entity_view, kind, EKIND_VEHICLE, 1) }, // NOTE(zaklaus): keep for vehicles
|
{ PKT_KEEP_IF(entity_view, kind, EKIND_VEHICLE, 1) }, // NOTE(zaklaus): keep for vehicles
|
||||||
{ PKT_HALF(entity_view, heading) },
|
{ PKT_HALF(entity_view, heading) },
|
||||||
{ PKT_UINT(entity_view, inside_vehicle) },
|
{ PKT_UINT(entity_view, inside_vehicle) },
|
||||||
|
{ PKT_UINT(entity_view, veh_kind) },
|
||||||
|
|
||||||
{ PKT_KEEP_IF(entity_view, kind, EKIND_ITEM, 2) },
|
{ PKT_KEEP_IF(entity_view, kind, EKIND_ITEM, 2) },
|
||||||
{ PKT_UINT(entity_view, asset) },
|
{ PKT_UINT(entity_view, asset) },
|
||||||
|
|
|
@ -57,6 +57,7 @@ typedef struct entity_view {
|
||||||
// NOTE(zaklaus): vehicle
|
// NOTE(zaklaus): vehicle
|
||||||
float heading, theading;
|
float heading, theading;
|
||||||
bool inside_vehicle;
|
bool inside_vehicle;
|
||||||
|
uint32_t veh_kind;
|
||||||
|
|
||||||
// NOTE(zaklaus): items, ...
|
// NOTE(zaklaus): items, ...
|
||||||
asset_id asset;
|
asset_id asset;
|
||||||
|
|
|
@ -56,6 +56,7 @@ entity_view *world_build_entity_view(int64_t e) {
|
||||||
if (ecs_get(world_ecs(), e, Vehicle)) {
|
if (ecs_get(world_ecs(), e, Vehicle)) {
|
||||||
Vehicle const* veh = ecs_get(world_ecs(), e, Vehicle);
|
Vehicle const* veh = ecs_get(world_ecs(), e, Vehicle);
|
||||||
view.heading = veh->heading;
|
view.heading = veh->heading;
|
||||||
|
view.veh_kind = veh->veh_kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecs_get(world_ecs(), e, Item)) {
|
if (ecs_get(world_ecs(), e, Item)) {
|
||||||
|
|
|
@ -123,9 +123,10 @@ void DEBUG_draw_entities_low(uint64_t key, entity_view * data) {
|
||||||
case EKIND_VEHICLE: {
|
case EKIND_VEHICLE: {
|
||||||
float x = data->x;
|
float x = data->x;
|
||||||
float y = data->y;
|
float y = data->y;
|
||||||
float const w = 80;
|
float const w = (float)(data->veh_kind == 0 ? 80 : data->veh_kind == 1 ? 120 : 135);
|
||||||
float const h = 50;
|
float const h = 50;
|
||||||
DrawRectanglePro((Rectangle){x,y,w,h}, (Vector2){w/2.0f,h/2.0f}, zpl_to_degrees(data->heading), ColorAlpha(RED, data->tran_time));
|
Color color = data->veh_kind == 0 ? RED : data->veh_kind == 1 ? GREEN : BLUE;
|
||||||
|
DrawRectanglePro((Rectangle){x,y,w,h}, (Vector2){w/2.0f,h/2.0f}, zpl_to_degrees(data->heading), ColorAlpha(color, data->tran_time));
|
||||||
}break;
|
}break;
|
||||||
case EKIND_DEVICE:{
|
case EKIND_DEVICE:{
|
||||||
float x = data->x - 32.f;
|
float x = data->x - 32.f;
|
||||||
|
|
|
@ -88,7 +88,7 @@ int32_t worldgen_build(world_data *wld) {
|
||||||
// vehicles
|
// vehicles
|
||||||
#if 1
|
#if 1
|
||||||
for (int i=0; i<RAND_RANGE(258, 1124); i++) {
|
for (int i=0; i<RAND_RANGE(258, 1124); i++) {
|
||||||
uint64_t e = vehicle_spawn();
|
uint64_t e = vehicle_spawn(RAND_RANGE(0,2));
|
||||||
|
|
||||||
Position *dest = ecs_get_mut(world_ecs(), e, Position);
|
Position *dest = ecs_get_mut(world_ecs(), e, Position);
|
||||||
dest->x = RAND_RANGEF(0, world->dim*WORLD_BLOCK_SIZE);
|
dest->x = RAND_RANGEF(0, world->dim*WORLD_BLOCK_SIZE);
|
||||||
|
|
Loading…
Reference in New Issue