naev 0.10.4
asteroid.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include "space_fdecl.h"
7
8#include "collision.h"
9#include "commodity.h"
10#include "opengl.h"
11#include "physics.h"
12#include "damagetype.h"
13#include "nxml.h"
14
15#define ASTEROID_DEFAULT_DENSITY 1.
16#define ASTEROID_DEFAULT_MAXSPEED 20.
17#define ASTEROID_DEFAULT_MAXSPIN M_PI/5
18#define ASTEROID_DEFAULT_THRUST 1.
20#define ASTEROID_REF_AREA 250e3
22/* Asteroid status enum. Order is based on how asteroids are generated. */
23enum {
24 ASTEROID_XX,
25 ASTEROID_XX_TO_BG,
26 ASTEROID_XB,
27 ASTEROID_BG_TO_FG,
28 ASTEROID_FG,
29 ASTEROID_FG_TO_BG,
30 ASTEROID_BX,
31 ASTEROID_BG_TO_XX,
32 ASTEROID_STATE_MAX,
33};
34
38typedef struct AsteroidReward_ {
41 int rarity;
43
47typedef struct AsteroidType_ {
48 char *name;
53 double armour_min;
54 double armour_max;
55 double absorb;
56 double damage;
57 double disable;
58 double penetration;
59 double exp_radius;
60 double alert_range;
62
66typedef struct AsteroidTypeGroup_ {
67 char *name;
69 double *weights;
70 double wtotal;
72
76typedef struct Asteroid_ {
77 /* Intrinsics. */
78 int id;
79 int parent;
80 int state;
82 const glTexture *gfx;
84 double armour;
85 /* Movement. */
88 double ang;
89 double spin;
90 /* Stats. */
91 double timer;
92 double timer_max;
93 double scan_alpha;
94 int scanned;
95} Asteroid;
96
100typedef struct AsteroidAnchor_ {
101 char *label;
102 int id;
104 double density;
106 int nb;
107 double radius;
108 double area;
110 double *groupsw;
112 double maxspeed;
113 double maxspin;
114 double thrust;
115 double margin;
117
121typedef struct AsteroidExclusion_ {
123 double radius;
126
127/* Initialization and parsing. */
128int asteroids_load (void);
129void asteroids_free (void);
130void asteroid_free( AsteroidAnchor *ast );
131void asteroids_init (void);
132
133/* Updating and rendering. */
134void asteroids_update( double dt );
135void asteroids_render (void);
136void asteroids_renderOverlay (void);
137
138/* Asteroid types. */
139const AsteroidType *asttype_getAll (void);
140AsteroidType *asttype_getName( const char *name );
141
142/* Asteroid type groups. */
144AsteroidTypeGroup *astgroup_getName( const char *name );
145
146/* Misc functions. */
147int asteroids_inField( const vec2 *p );
149void asteroid_hit( Asteroid *a, const Damage *dmg, int max_rarity, double mine_bonus );
150void asteroid_explode( Asteroid *a, int max_rarity, double mine_bonus );
void asteroids_render(void)
Renders the current systems' spobs.
Definition: asteroid.c:785
void asteroids_computeInternals(AsteroidAnchor *a)
Updates internal alues of an asteroid field.
Definition: asteroid.c:407
void asteroids_free(void)
Cleans up the system.
Definition: asteroid.c:902
void asteroid_hit(Asteroid *a, const Damage *dmg, int max_rarity, double mining_bonus)
Hits an asteroid.
Definition: asteroid.c:1031
int asteroids_load(void)
Loads the asteroids.
Definition: asteroid.c:429
AsteroidType * asttype_getName(const char *name)
Gets the ID of an asteroid type by name.
Definition: asteroid.c:989
const AsteroidTypeGroup * astgroup_getAll(void)
Gets all the asteroid type groups.
Definition: asteroid.c:1003
void asteroid_free(AsteroidAnchor *ast)
Frees an asteroid anchor.
Definition: asteroid.c:891
AsteroidTypeGroup * astgroup_getName(const char *name)
Gets an asteroid type group by name.
Definition: asteroid.c:1014
void asteroid_explode(Asteroid *a, int max_rarity, double mining_bonus)
Makes an asteroid explode.
Definition: asteroid.c:1049
void asteroids_init(void)
Initializes the system.
Definition: asteroid.c:238
void asteroids_renderOverlay(void)
Renders the system overlay.
Definition: asteroid.c:767
const AsteroidType * asttype_getAll(void)
Gets all the asteroid types.
Definition: asteroid.c:978
int asteroids_inField(const vec2 *p)
See if the position is in an asteroid field.
Definition: asteroid.c:954
void asteroids_update(double dt)
Controls fleet spawning.
Definition: asteroid.c:74
Represents an asteroid field anchor.
Definition: asteroid.h:100
double margin
Definition: asteroid.h:115
double area
Definition: asteroid.h:108
double radius
Definition: asteroid.h:107
double density
Definition: asteroid.h:104
double maxspin
Definition: asteroid.h:113
char * label
Definition: asteroid.h:101
double * groupsw
Definition: asteroid.h:110
double thrust
Definition: asteroid.h:114
double maxspeed
Definition: asteroid.h:112
Asteroid * asteroids
Definition: asteroid.h:105
double groupswtotal
Definition: asteroid.h:111
AsteroidTypeGroup ** groups
Definition: asteroid.h:109
Represents an asteroid exclusion zone.
Definition: asteroid.h:121
Represents a potential reward from the asteroid.
Definition: asteroid.h:38
Commodity * material
Definition: asteroid.h:39
Represents a group of asteroids.
Definition: asteroid.h:66
double * weights
Definition: asteroid.h:69
AsteroidType ** types
Definition: asteroid.h:68
Represents a type of asteroid.
Definition: asteroid.h:47
double exp_radius
Definition: asteroid.h:59
double penetration
Definition: asteroid.h:58
double alert_range
Definition: asteroid.h:60
double armour_max
Definition: asteroid.h:54
CollPoly * polygon
Definition: asteroid.h:51
double armour_min
Definition: asteroid.h:53
double damage
Definition: asteroid.h:56
char * name
Definition: asteroid.h:48
AsteroidReward * material
Definition: asteroid.h:52
double absorb
Definition: asteroid.h:55
char * scanned_msg
Definition: asteroid.h:49
double disable
Definition: asteroid.h:57
glTexture ** gfxs
Definition: asteroid.h:50
Represents a single asteroid.
Definition: asteroid.h:76
CollPoly * polygon
Definition: asteroid.h:83
int id
Definition: asteroid.h:78
double timer
Definition: asteroid.h:91
int state
Definition: asteroid.h:80
double scan_alpha
Definition: asteroid.h:93
vec2 vel
Definition: asteroid.h:87
double timer_max
Definition: asteroid.h:92
int parent
Definition: asteroid.h:79
double armour
Definition: asteroid.h:84
const glTexture * gfx
Definition: asteroid.h:82
vec2 pos
Definition: asteroid.h:86
int scanned
Definition: asteroid.h:94
const AsteroidType * type
Definition: asteroid.h:81
double ang
Definition: asteroid.h:88
double spin
Definition: asteroid.h:89
Represents a polygon used for collision detection.
Definition: collision.h:13
Represents a commodity.
Definition: commodity.h:43
Core damage that an outfit does.
Definition: outfit.h:111
Abstraction for rendering sprite sheets.
Definition: opengl_tex.h:34
Represents a 2d vector.
Definition: vec2.h:32