naev 0.12.6
gatherable.c File Reference

Handles gatherable objects. More...

#include "gatherable.h"
#include "array.h"
#include "hook.h"
#include "player.h"
#include "rng.h"
Include dependency graph for gatherable.c:

Go to the source code of this file.

Macros

#define GATHER_DIST   30.

Functions

static int gatherable_gather (Gatherable *gat, Pilot *p)
 See if the pilot can gather anything.
int gatherable_load (void)
 Loads the gatherable system.
void gatherable_cleanup (void)
 Cleans up after the gatherable system.
int gatherable_init (const Commodity *com, const vec2 *pos, const vec2 *vel, double lifeleng, int qtt, unsigned int player_only)
 Initializes a gatherable object.
void gatherable_update (double dt)
 Updates all gatherable objects.
void gatherable_free (void)
 Frees all the gatherables.
void gatherable_render (void)
 Renders all the gatherables.
int gatherable_getClosest (const vec2 *pos, double rad)
 Gets the closest gatherable from a given position, within a given radius.
int gatherable_getPos (vec2 *pos, vec2 *vel, int id)
 Returns the position and velocity of a gatherable.

Variables

static Gatherablegatherable_stack
static float noscoop_timer = 1.
static IntList gather_qtquery

Detailed Description

Handles gatherable objects.

Definition in file gatherable.c.

Macro Definition Documentation

◆ GATHER_DIST

#define GATHER_DIST   30.

Maximum distance a gatherable can be gathered.

Definition at line 24 of file gatherable.c.

Function Documentation

◆ gatherable_cleanup()

void gatherable_cleanup ( void )

Cleans up after the gatherable system.

Definition at line 50 of file gatherable.c.

◆ gatherable_free()

void gatherable_free ( void )

Frees all the gatherables.

Definition at line 147 of file gatherable.c.

◆ gatherable_gather()

int gatherable_gather ( Gatherable * gat,
Pilot * p )
static

See if the pilot can gather anything.

Parameters
gatGatherable to try to gather.
pPilot to try to gather for.

Definition at line 220 of file gatherable.c.

◆ gatherable_getClosest()

int gatherable_getClosest ( const vec2 * pos,
double rad )

Gets the closest gatherable from a given position, within a given radius.

Parameters
posposition.
radradius.
Returns
The id of the closest gatherable, or -1 if none is found.

Definition at line 173 of file gatherable.c.

◆ gatherable_getPos()

int gatherable_getPos ( vec2 * pos,
vec2 * vel,
int id )

Returns the position and velocity of a gatherable.

Parameters
pospointer to the position.
velpointer to the velocity.
idId of the gatherable in the stack.
Returns
flag 1->there exists a gatherable 0->elsewere.

Definition at line 197 of file gatherable.c.

◆ gatherable_init()

int gatherable_init ( const Commodity * com,
const vec2 * pos,
const vec2 * vel,
double lifeleng,
int qtt,
unsigned int player_only )

Initializes a gatherable object.

Parameters
comType of commodity.
posPosition.
velVelocity.
lifelengDuration in seconds.
qttQuantity to add.
player_onlyWhether the gatherable can only be gathered by the player.

Definition at line 68 of file gatherable.c.

◆ gatherable_load()

int gatherable_load ( void )

Loads the gatherable system.

Returns
0 on success.

Definition at line 40 of file gatherable.c.

◆ gatherable_render()

void gatherable_render ( void )

Renders all the gatherables.

Definition at line 156 of file gatherable.c.

◆ gatherable_update()

void gatherable_update ( double dt)

Updates all gatherable objects.

Parameters
dtElapsed time.

Definition at line 95 of file gatherable.c.

Variable Documentation

◆ gather_qtquery

IntList gather_qtquery
static

For collisions.

Definition at line 30 of file gatherable.c.

◆ gatherable_stack

Gatherable* gatherable_stack
static
Initial value:
=
NULL

Contains the gatherable stuff floating around.

Definition at line 27 of file gatherable.c.

◆ noscoop_timer

float noscoop_timer = 1.
static

Timer for the "full cargo" message .

Definition at line 29 of file gatherable.c.