Nimbin[12]?Games / Entropie / entropie/src/world/car.h

Entropie git · main

Entropie festival game; first steps

sdl c game entropie cmake · first commit 2026-10-10 · last commit 2026-11-02 (18 hours ago) · synced 10 hours ago

C 88.5% Markdown 9.1% GLSL 2.3%
git clone https://git.christianimmanuel.de/games/Entropie.gitwget https://git.christianimmanuel.de/games/Entropie/archive/Entropie.tar.gz
entropie/src/world/car.h 5.3 KB · 100 lines raw
#ifndef WORLD_CAR_H
#define WORLD_CAR_H

/*
 * Your car (OBJ_CAR, an estate): it drives in at the start (moved by hand,
 * see game_arrival.c), the ones in it riding (hidden, no physics, no AI).
 * Its boot holds what you brought - crates of beer and water (OBJ_CRATE),
 * sleeping bags, mats and tents (OBJ_GEAR, each somebody's), later the
 * shopping (OBJ_MATERIAL, food boxes: game_shop.c) - taken out one
 * by one: you click at the open boot, the others unload (ai.c unloadCar).
 * Crates hand out bottles: you click one, the others ask (ai.take_from).
 */

#include "world/world.h"


typedef enum { GEAR_SLEEPING_BAG, GEAR_MAT, GEAR_TENT_SMALL, GEAR_TENT_BIG } GearKind;
typedef enum { CARGO_BEER, CARGO_WATER, CARGO_SLEEPING_BAG, CARGO_MAT, CARGO_TENT_SMALL, CARGO_TENT_BIG, CARGO_SODA, CARGO_MATE,
               CARGO_BOARDS, CARGO_NAILS, CARGO_SCREWS, CARGO_PAINT, /* (from the hardware store: OBJ_MATERIAL) */
               CARGO_FOOD, CARGO_SAUSAGES /* (a food crate, a cool box of sausages: OBJ_SUPPLY that run out) */ } CargoKind;

#define FOOD_PORTIONS    40 /* a food crate: this many go at it */
#define SAUSAGE_PORTIONS 24

/* Crates: 0 beer, 1 water, 2 soda (cola and orange), 3 mate - how many bottles, how heavy each, its name. */
int         Crate_bottles(int variant);
float       Crate_bottleKg(int variant);
const char *Crate_name(int variant);

#define CAR_LOAD_MAX 32
typedef struct CarLoad {
    int       n;
    CargoKind kind[CAR_LOAD_MAX];
    Object   *owner[CAR_LOAD_MAX];
} CarLoad;

/* A car with an empty boot (shut). */
Object     *Car_create(Vec3 position, float yaw);
bool        Car_load(Object *car, CargoKind kind, Object *owner);
/* What comes out next ("A crate of beer"), NULL: the boot is empty. */
const char *Car_nextName(const Object *car);
/* ... and whether it takes both hands. */
bool        Car_nextHeavy(const Object *car);
/* The next thing out of the (open) boot, lying at its edge: NULL if empty or shut. */
Object     *Car_takeOut(World *world, Object *car);
/* Where one stands to reach into the boot (behind it). */
Vec3        Car_bootSpot(const Object *car);
/* Seat k (0 the driver, 1 beside, 2 and 3 behind): the eye, and where they stand once out. */
Vec3        Car_eye(const Object *car, int seat);
Vec3        Car_door(const Object *car, int seat);
/* Moves it (and whoever rides in it) here, facing yaw (rotation.y), on the ground. */
void        Car_place(World *world, Object *car, Vec3 at, float yaw);
void        Car_getIn(Object *car, Object *who, int seat);
void        Car_getOut(Object *who);
void        Car_openBoot(Object *car, bool open);

/* Where an unloaded thing goes: crates and food into the kitchen, material in front of the car room (the store),
   the camping things where its owner's tent will be (the tent bag on the spot, sleeping bags and mats
   CAMP_BEDS_OUT in front of its door). */
#define CAMP_BEDS_OUT 2.8f
Vec3        Car_campDoor(void);
Vec3        Car_dropSpot(const World *world, const Object *item);

/* Crates know what's in each slot (Object.crate_slot): their own bottles,
   full or empty, and bottles of other kinds put back into the wrong crate
   (they have to be sorted before the crates go back to the shop). */
/* Full of its own bottles (a new crate); and stored, crate_empties, weight from the slots. */
void        Crate_fill(Object *crate);
void        Crate_recount(Object *crate);
/* A slot's worth for the look (its mesh is built again when this changes). */
int         Crate_look(const Object *crate);
/* Which kind of bottle (BOTTLE_KIND_*: one that comes in crates), else BOTTLE_KIND_NONE. */
int         Crate_bottleKind(const Object *bottle);
/* Does a bottle of that kind belong in this crate? */
bool        Crate_belongs(const Object *crate, int kind);
/* How many bottles of other kinds are in it; the kind Crate_takeWrong takes out next (or none). */
int         Crate_wrong(const Object *crate);
int         Crate_nextWrong(const Object *crate);
/* A bottle to drink out of a crate (its own first, else any full one), lying on top of it: NULL if none. */
Object     *Crate_takeBottle(World *world, Object *crate);
/* A bottle that doesn't belong in it, out (full or empty): NULL if none. */
Object     *Crate_takeWrong(World *world, Object *crate);
/* A bottle (empty or not, as it is) into a crate with room: true if it went in. */
bool        Crate_putBottle(Object *crate, Object *bottle);
/* The crate a bottle goes into within range (not carried, room in it): its own kind first, else any. */
Object     *Crate_forBottle(Object *const *objects, int count, const Object *bottle, Vec3 at, float range);
/* A crate where a bottle of that kind belongs, with room, within range (nearest), or NULL. */
Object     *Crate_rightFor(Object *const *objects, int count, int kind, Vec3 at, float range);
/* The nearest crate within range with room for one more (not carried), or NULL. */
Object     *Crate_withRoom(Object *const *objects, int count, Vec3 at, float range);
/* Every frame: whoever asked for a bottle from a crate or the next thing from
   the boot (ai.take_from) gets it lying there for them (ai.target). */
void        Car_serve(World *world);

/* Somebody's camping thing (OBJ_GEAR) lying at `at` (not added to the world yet), or NULL. */
Object *Gear_create(GearKind kind, Object *owner, Vec3 at);
/* Its look again in its owner's colours (after loading a save). */
void    Gear_refresh(Object *gear);

#endif /* WORLD_CAR_H */