naev 0.11.5
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#include "quadtree.h"
15
16#define ASTEROID_DEFAULT_DENSITY 1.
17#define ASTEROID_DEFAULT_MAXSPEED 20.
18#define ASTEROID_DEFAULT_MAXSPIN M_PI/5
19#define ASTEROID_DEFAULT_ACCEL 1.
21#define ASTEROID_REF_AREA 250e3
23/* Asteroid status enum. Order is based on how asteroids are generated. */
24enum {
25 ASTEROID_XX,
26 ASTEROID_XX_TO_BG,
27 ASTEROID_XB,
28 ASTEROID_BG_TO_FG,
29 ASTEROID_FG,
30 ASTEROID_FG_TO_BG,
31 ASTEROID_BX,
32 ASTEROID_BG_TO_XX,
33 ASTEROID_STATE_MAX,
34};
35
39typedef struct AsteroidReward_ {
42 int rarity;
44
48typedef struct AsteroidType_ {
49 char *name;
54 double armour_min;
55 double armour_max;
56 double absorb;
57 double damage;
58 double disable;
59 double penetration;
60 double exp_radius;
61 double alert_range;
63
67typedef struct AsteroidTypeGroup_ {
68 char *name;
70 double *weights;
71 double wtotal;
73
77typedef struct Asteroid_ {
78 /* Intrinsics. */
79 int id;
80 int parent;
81 int state;
83 const glTexture *gfx;
85 double armour;
86 /* 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 accel;
115 double margin;
116 /* Collision stuff. */
120
124typedef struct AsteroidExclusion_ {
126 double radius;
129
130/* Initialization and parsing. */
131int asteroids_load (void);
132void asteroids_free (void);
133void asteroid_free( AsteroidAnchor *ast );
134void asteroids_init (void);
135
136/* Updating and rendering. */
137void asteroids_update( double dt );
138void asteroids_render (void);
139void asteroids_renderOverlay (void);
140
141/* Asteroid types. */
142const AsteroidType *asttype_getAll (void);
143AsteroidType *asttype_getName( const char *name );
144
145/* Asteroid type groups. */
147AsteroidTypeGroup *astgroup_getName( const char *name );
148
149/* Misc functions. */
150int asteroids_inField( const vec2 *p );
152void asteroid_hit( Asteroid *a, const Damage *dmg, int max_rarity, double mine_bonus );
153void asteroid_explode( Asteroid *a, int max_rarity, double mine_bonus );
154void asteroid_collideQueryIL( AsteroidAnchor *anc, IntList *il, int x1, int y1, int x2, int y2 );
void asteroids_render(void)
Renders the current systems' spobs.
Definition asteroid.c:817
void asteroids_computeInternals(AsteroidAnchor *a)
Updates internal alues of an asteroid field.
Definition asteroid.c:439
void asteroids_free(void)
Cleans up the system.
Definition asteroid.c:947
void asteroid_hit(Asteroid *a, const Damage *dmg, int max_rarity, double mining_bonus)
Hits an asteroid.
Definition asteroid.c:1074
int asteroids_load(void)
Loads the asteroids.
Definition asteroid.c:461
AsteroidType * asttype_getName(const char *name)
Gets the ID of an asteroid type by name.
Definition asteroid.c:1032
const AsteroidTypeGroup * astgroup_getAll(void)
Gets all the asteroid type groups.
Definition asteroid.c:1046
void asteroid_free(AsteroidAnchor *ast)
Frees an asteroid anchor.
Definition asteroid.c:934
AsteroidTypeGroup * astgroup_getName(const char *name)
Gets an asteroid type group by name.
Definition asteroid.c:1057
void asteroid_explode(Asteroid *a, int max_rarity, double mining_bonus)
Makes an asteroid explode.
Definition asteroid.c:1092
void asteroids_init(void)
Initializes the system.
Definition asteroid.c:253
void asteroids_renderOverlay(void)
Renders the system overlay.
Definition asteroid.c:799
const AsteroidType * asttype_getAll(void)
Gets all the asteroid types.
Definition asteroid.c:1021
int asteroids_inField(const vec2 *p)
See if the position is in an asteroid field.
Definition asteroid.c:997
void asteroids_update(double dt)
Controls fleet spawning.
Definition asteroid.c:73
Represents an asteroid field anchor.
Definition asteroid.h:100
double margin
Definition asteroid.h:115
Quadtree qt
Definition asteroid.h:117
double radius
Definition asteroid.h:107
double density
Definition asteroid.h:104
double maxspin
Definition asteroid.h:113
double * groupsw
Definition asteroid.h:110
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:124
Represents a potential reward from the asteroid.
Definition asteroid.h:39
Commodity * material
Definition asteroid.h:40
Represents a group of asteroids.
Definition asteroid.h:67
double * weights
Definition asteroid.h:70
AsteroidType ** types
Definition asteroid.h:69
Represents a type of asteroid.
Definition asteroid.h:48
double exp_radius
Definition asteroid.h:60
double penetration
Definition asteroid.h:59
double alert_range
Definition asteroid.h:61
double armour_max
Definition asteroid.h:55
CollPoly * polygon
Definition asteroid.h:52
double armour_min
Definition asteroid.h:54
double damage
Definition asteroid.h:57
char * name
Definition asteroid.h:49
AsteroidReward * material
Definition asteroid.h:53
double absorb
Definition asteroid.h:56
char * scanned_msg
Definition asteroid.h:50
double disable
Definition asteroid.h:58
glTexture ** gfxs
Definition asteroid.h:51
Represents a single asteroid.
Definition asteroid.h:77
CollPoly * polygon
Definition asteroid.h:84
int id
Definition asteroid.h:79
double timer
Definition asteroid.h:91
int state
Definition asteroid.h:81
double scan_alpha
Definition asteroid.h:93
double timer_max
Definition asteroid.h:92
int parent
Definition asteroid.h:80
double armour
Definition asteroid.h:85
const glTexture * gfx
Definition asteroid.h:83
Solid sol
Definition asteroid.h:87
int scanned
Definition asteroid.h:94
const AsteroidType * type
Definition asteroid.h:82
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:138
Represents a solid in the game.
Definition physics.h:44
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:36
Represents a 2d vector.
Definition vec2.h:32