naev 0.12.5
asteroid.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include "space_fdecl.h" // IWYU pragma: keep
7
8#include "collision.h"
9#include "commodity.h"
10#include "opengl.h"
11#include "outfit.h"
12#include "physics.h"
13#include "quadtree.h"
14
15#define ASTEROID_DEFAULT_RADIUS \
16 2500.
17#define ASTEROID_DEFAULT_DENSITY \
18 1.
19#define ASTEROID_DEFAULT_MAXSPEED \
20 20.
21#define ASTEROID_DEFAULT_MAXSPIN \
22 M_PI / 5
23#define ASTEROID_DEFAULT_ACCEL \
24 1.
25
26#define ASTEROID_REF_AREA \
27 250e3
29
30/* Asteroid status enum. Order is based on how asteroids are generated. */
31enum {
32 ASTEROID_XX,
33 ASTEROID_XX_TO_BG,
34 ASTEROID_XB,
36 ASTEROID_BG_TO_FG,
38 ASTEROID_FG,
39 ASTEROID_FG_TO_BG,
41 ASTEROID_BX,
43 ASTEROID_BG_TO_XX,
44 ASTEROID_STATE_MAX,
45};
46
50typedef struct AsteroidReward_ {
53 int rarity;
55
59typedef struct AsteroidType_ {
60 char *name;
65 double armour_min;
66 double armour_max;
67 double absorb;
68 double damage;
69 double disable;
70 double penetration;
71 double exp_radius;
72 double alert_range;
74
78typedef struct AsteroidTypeGroup_ {
79 char *name;
81 double *weights;
82 double wtotal;
84
88typedef struct Asteroid_ {
89 /* Intrinsics. */
90 int id;
91 int parent;
92 int state;
94 const glTexture *gfx;
96 double armour;
97 /* Movement. */
99 double ang;
100 double spin;
101 /* Stats. */
102 double timer;
103 double timer_max;
104 double scan_alpha;
106} Asteroid;
107
111typedef struct AsteroidAnchor_ {
112 char *label;
113 int id;
115 double density;
117 int nmax;
118 double radius;
119 double area;
121 double *groupsw;
123 double maxspeed;
124 double maxspin;
125 double accel;
126 double margin;
127 /* Collision stuff. */
132
136typedef struct AsteroidExclusion_ {
137 char *label;
139 double radius;
142
143/* Initialization and parsing. */
144int asteroids_load( void );
145void asteroids_free( void );
149void asteroids_init( void );
150
151/* Updating and rendering. */
152void asteroids_update( double dt );
153void asteroids_render( void );
154void asteroids_renderOverlay( void );
155
156/* Asteroid types. */
157const AsteroidType *asttype_getAll( void );
158AsteroidType *asttype_getName( const char *name );
159
160/* Asteroid type groups. */
162AsteroidTypeGroup *astgroup_getName( const char *name );
163
164/* Misc functions. */
165int asteroids_inField( const vec2 *p );
167void asteroid_hit( Asteroid *a, const Damage *dmg, int max_rarity,
168 double mine_bonus );
169void asteroid_explode( Asteroid *a, int max_rarity, double mine_bonus );
170void asteroid_collideQueryIL( AsteroidAnchor *anc, IntList *il, int x1, int y1,
171 int x2, int y2 );
void asteroids_render(void)
Renders the current systems' spobs.
Definition asteroid.c:897
void asteroids_computeInternals(AsteroidAnchor *a)
Updates internal alues of an asteroid field.
Definition asteroid.c:508
void asteroids_free(void)
Cleans up the system.
Definition asteroid.c:1059
void asteroid_hit(Asteroid *a, const Damage *dmg, int max_rarity, double mining_bonus)
Hits an asteroid.
Definition asteroid.c:1189
int asteroids_load(void)
Loads the asteroids.
Definition asteroid.c:532
void asteroid_freeAnchor(AsteroidAnchor *ast)
Frees an asteroid anchor.
Definition asteroid.c:1036
AsteroidType * asttype_getName(const char *name)
Gets the ID of an asteroid type by name.
Definition asteroid.c:1144
const AsteroidTypeGroup * astgroup_getAll(void)
Gets all the asteroid type groups.
Definition asteroid.c:1159
AsteroidTypeGroup * astgroup_getName(const char *name)
Gets an asteroid type group by name.
Definition asteroid.c:1170
void asteroid_explode(Asteroid *a, int max_rarity, double mining_bonus)
Makes an asteroid explode.
Definition asteroid.c:1209
void asteroids_init(void)
Initializes the system.
Definition asteroid.c:298
void asteroids_renderOverlay(void)
Renders the system overlay.
Definition asteroid.c:875
void asteroid_initAnchor(AsteroidAnchor *ast)
Initializes an asteroid anchor.
Definition asteroid.c:1019
void asteroid_freeExclude(AsteroidExclusion *exc)
Frees an asteroid exclusion.
Definition asteroid.c:1051
const AsteroidType * asttype_getAll(void)
Gets all the asteroid types.
Definition asteroid.c:1133
int asteroids_inField(const vec2 *p)
See if the position is in an asteroid field.
Definition asteroid.c:1109
void asteroids_update(double dt)
Controls fleet spawning.
Definition asteroid.c:203
Represents an asteroid field anchor.
Definition asteroid.h:111
double margin
Definition asteroid.h:126
Quadtree qt
Definition asteroid.h:128
double radius
Definition asteroid.h:118
double density
Definition asteroid.h:115
double maxspin
Definition asteroid.h:124
double * groupsw
Definition asteroid.h:121
double maxspeed
Definition asteroid.h:123
Asteroid * asteroids
Definition asteroid.h:116
double groupswtotal
Definition asteroid.h:122
AsteroidTypeGroup ** groups
Definition asteroid.h:120
Represents an asteroid exclusion zone.
Definition asteroid.h:136
Represents a potential reward from the asteroid.
Definition asteroid.h:50
Commodity * material
Definition asteroid.h:51
Represents a group of asteroids.
Definition asteroid.h:78
double * weights
Definition asteroid.h:81
AsteroidType ** types
Definition asteroid.h:80
Represents a type of asteroid.
Definition asteroid.h:59
double exp_radius
Definition asteroid.h:71
double penetration
Definition asteroid.h:70
double alert_range
Definition asteroid.h:72
double armour_max
Definition asteroid.h:66
CollPoly * polygon
Definition asteroid.h:63
double armour_min
Definition asteroid.h:65
double damage
Definition asteroid.h:68
char * name
Definition asteroid.h:60
AsteroidReward * material
Definition asteroid.h:64
double absorb
Definition asteroid.h:67
char * scanned_msg
Definition asteroid.h:61
double disable
Definition asteroid.h:69
glTexture ** gfxs
Definition asteroid.h:62
Represents a single asteroid.
Definition asteroid.h:88
CollPoly * polygon
Definition asteroid.h:95
int id
Definition asteroid.h:90
double timer
Definition asteroid.h:102
int state
Definition asteroid.h:92
double scan_alpha
Definition asteroid.h:104
double timer_max
Definition asteroid.h:103
int parent
Definition asteroid.h:91
double armour
Definition asteroid.h:96
const glTexture * gfx
Definition asteroid.h:94
Solid sol
Definition asteroid.h:98
int scanned
Definition asteroid.h:105
const AsteroidType * type
Definition asteroid.h:93
double ang
Definition asteroid.h:99
double spin
Definition asteroid.h:100
Represents a commodity.
Definition commodity.h:57
Core damage that an outfit does.
Definition outfit.h:168
Represents a solid in the game.
Definition physics.h:44
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43
Represents a 2d vector.
Definition vec2.h:45