16#include "gatherable.h"
24#define GATHER_DIST 30.
69 double lifeleng,
int qtt,
unsigned int player_only )
80 g->player_only = player_only;
83 g->lifeleng = RNGF() * 100. + 50.;
85 g->lifeleng = lifeleng;
108 g->pos.x += dt * g->vel.x;
109 g->pos.y += dt * g->vel.y;
112 if ( g->timer > g->lifeleng ) {
118 if ( g->player_only ) {
119 if ( (
player.p != NULL ) &&
120 vec2_dist2( &
player.p->solid.pos, &g->pos ) <=
127 x = round( g->pos.x );
128 y = round( g->pos.y );
129 pilot_collideQueryIL( &
gather_qtquery, x - r, y - r, x + r, y + r );
176 double mindist = INFINITY;
180 double curdist = vec2_dist( pos, &gat->
pos );
181 if ( ( curdist < mindist ) && ( curdist < rad ) ) {
225 if ( pilot_isFlag( p, PILOT_DELETE ) || pilot_isFlag( p, PILOT_DEAD ) )
229 if ( pilot_isFlag( p, PILOT_HIDE ) || pilot_isFlag( p, PILOT_INVISIBLE ) )
233 if ( pilot_isDisabled( p ) )
240 if ( pilot_isPlayer( p ) ) {
243 n_(
"%d ton of %s gathered",
"%d tons of %s gathered", q ), q,
247 hparam[0].
type = HOOK_PARAM_COMMODITY;
249 hparam[1].
type = HOOK_PARAM_NUMBER;
251 hparam[2].
type = HOOK_PARAM_SENTINEL;
262 }
else if ( ( pilot_isPlayer( p ) ) && (
noscoop_timer > 2. ) ) {
265 _(
"Cannot gather material: no more cargo space available" ) );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_end(array)
Returns a pointer to the end of the reserved memory space.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_begin(array)
Returns a pointer to the beginning of the reserved memory space.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
int gatherable_getPos(vec2 *pos, vec2 *vel, int id)
Returns the position and velocity of a gatherable.
void gatherable_free(void)
Frees all the gatherables.
int gatherable_init(const Commodity *com, const vec2 *pos, const vec2 *vel, double lifeleng, int qtt, unsigned int player_only)
Initializes a gatherable object.
int gatherable_getClosest(const vec2 *pos, double rad)
Gets the closest gatherable from a given position, within a given radius.
int gatherable_load(void)
Loads the gatherable system.
void gatherable_cleanup(void)
Cleans up after the gatherable system.
static IntList gather_qtquery
static Gatherable * gatherable_stack
static int gatherable_gather(Gatherable *got, Pilot *p)
See if the pilot can gather anything.
void gatherable_update(double dt)
Updates all gatherable objects.
static float noscoop_timer
void gatherable_render(void)
Renders all the gatherables.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
Header file with generic functions and naev-specifics.
void gl_renderSprite(const glTexture *sprite, double bx, double by, int sx, int sy, const glColour *c)
Blits a sprite, position is relative to the player.
static Pilot ** pilot_stack
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
int pilot_cargoAdd(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Tries to add quantity of cargo to pilot.
Represents stuff that can be gathered.
The actual hook parameter.
union HookParam::@325330313164266255110350307176363262300250041145 u
The representation of an in-game pilot.