naev 0.10.4
Macros | Functions | Variables
gatherable.c File Reference

Handles gatherable objects. More...

#include "gatherable.h"
#include "array.h"
#include "hook.h"
#include "player.h"

Go to the source code of this file.

Macros

#define GATHER_DIST   30.
 

Functions

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

Variables

static Gatherablegatherable_stack = NULL
 
static float noscoop_timer = 1.
 

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  )

Definition at line 36 of file gatherable.c.

◆ gatherable_free()

void gatherable_free ( void  )

Frees all the gatherables.

Definition at line 99 of file gatherable.c.

◆ gatherable_gather()

void gatherable_gather ( Pilot p)

See if the pilot can gather anything.

Parameters
pPilot to try to gather for.

Definition at line 168 of file gatherable.c.

◆ gatherable_getClosest()

int gatherable_getClosest ( 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 122 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 146 of file gatherable.c.

◆ gatherable_init()

int gatherable_init ( const Commodity com,
vec2  pos,
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 52 of file gatherable.c.

◆ gatherable_load()

int gatherable_load ( void  )

Definition at line 30 of file gatherable.c.

◆ gatherable_render()

void gatherable_render ( void  )

Renders all the gatherables.

Definition at line 107 of file gatherable.c.

◆ gatherable_update()

void gatherable_update ( double  dt)

Updates all gatherable objects.

Parameters
dtElapsed time.

Definition at line 77 of file gatherable.c.

Variable Documentation

◆ gatherable_stack

Gatherable* gatherable_stack = NULL
static

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 28 of file gatherable.c.