143ad0da8428d3e49d9525ef2a30bcf8db613ae7
[carveJwlIkooP6JGAAIwe30JlM.git] / entity.h
1 #ifndef ENTITY_H
2 #define ENTITY_H
3
4 #include "model.h"
5
6 typedef struct ent_spawn ent_spawn;
7 typedef struct ent_light ent_light;
8 typedef struct ent_gate ent_gate;
9 typedef struct ent_route_node ent_route_node;
10 typedef struct ent_path_index ent_path_index;
11 typedef struct ent_checkpoint ent_checkpoint;
12 typedef struct ent_route ent_route;
13 typedef struct ent_water ent_water;
14 typedef struct ent_audio_clip ent_audio_clip;
15 typedef struct volume_particles volume_particles;
16 typedef struct volume_trigger volume_trigger;
17 typedef struct ent_volume ent_volume;
18 typedef struct ent_audio ent_audio;
19 typedef struct ent_index ent_index;
20 typedef struct ent_marker ent_marker;
21 typedef struct ent_font ent_font;
22 typedef struct ent_font_variant ent_font_variant;
23 typedef struct ent_glyph ent_glyph;
24
25 enum entity_alias{
26 k_ent_gate = 1,
27 k_ent_spawn = 2,
28 k_ent_route_node = 3,
29 k_ent_route = 4,
30 k_ent_water = 5,
31 k_ent_volume = 6,
32 k_ent_audio = 7,
33 k_ent_marker = 8
34 };
35
36 struct ent_index{
37 u32 type,
38 index;
39 };
40
41 enum entity_function{
42 k_ent_function_trigger,
43 k_ent_function_particle_spawn
44 };
45
46 struct ent_spawn{
47 mdl_transform transform;
48 u32 pstr_name;
49 };
50
51 enum light_type{
52 k_light_type_point = 0,
53 k_light_type_spot = 1
54 };
55
56 struct ent_light{
57 mdl_transform transform;
58 u32 daytime,
59 type;
60
61 v4f colour;
62 float angle,
63 range;
64
65 m4x3f inverse_world;
66 v2f angle_sin_cos;
67 };
68
69 enum gate_type{
70 k_gate_type_unlinked = 0,
71 k_gate_type_teleport = 1,
72 k_gate_type_nonlocal = 2
73 };
74
75 struct ent_gate{
76 u32 type,
77 target;
78
79 /* TODO: World index */
80
81 v3f dimensions,
82 co[2];
83
84 v4f q[2];
85
86 /* runtime */
87 m4x3f to_world, transport;
88
89 union{
90 u32 timing_version;
91
92 struct{
93 u8 ref_count;
94 };
95 };
96
97 double timing_time;
98 u16 routes[4]; /* routes that pass through this gate */
99 u8 route_count;
100 };
101
102 struct ent_route_node{
103 v3f co;
104 u8 ref_count, ref_total;
105 };
106
107 struct ent_path_index{
108 u16 index;
109 };
110
111 struct ent_checkpoint{
112 u16 gate_index,
113 path_start,
114 path_count;
115 };
116
117 struct ent_route{
118
119 union{
120 mdl_transform transform;
121 u32 official_track_id;
122 };
123
124 u32 pstr_name;
125 u16 checkpoints_start,
126 checkpoints_count;
127
128 v4f colour;
129
130 /* runtime */
131 u16 active_checkpoint,
132 valid_checkpoints;
133
134 float factive;
135 m4x3f board_transform;
136 mdl_submesh sm;
137 double timing_base;
138 };
139
140 struct ent_water{
141 mdl_transform transform;
142 float max_dist;
143 u32 reserved0, reserved1;
144 };
145
146 struct ent_audio_clip{
147 union{
148 mdl_file file;
149 audio_clip clip;
150 };
151
152 float probability;
153 };
154
155 struct volume_particles{
156 u32 blank, blank2;
157 };
158
159 struct volume_trigger{
160 u32 event, blank;
161 };
162
163 enum volume_subtype{
164 k_volume_subtype_trigger,
165 k_volume_subtype_particle
166 };
167
168 struct ent_volume{
169 mdl_transform transform;
170 m4x3f to_world, to_local;
171 u32 type;
172
173 ent_index target;
174
175 union{
176 volume_trigger trigger;
177 volume_particles particles;
178 };
179 };
180
181 struct ent_audio{
182 mdl_transform transform;
183 u32 flags,
184 clip_start,
185 clip_count;
186 float volume, crossfade;
187 u32 behaviour,
188 group,
189 probability_curve,
190 max_channels;
191 };
192
193 struct ent_marker{
194 mdl_transform transform;
195 u32 pstr_alias;
196 };
197
198 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
199 mdl_array_ptr *arr, const char *alias )
200 {
201 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
202 ent_marker *marker = mdl_arritm( arr, i );
203
204 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
205 return marker;
206 }
207 }
208
209 return NULL;
210 }
211
212 enum channel_behaviour{
213 k_channel_behaviour_unlimited = 0,
214 k_channel_behaviour_discard_if_full = 1,
215 k_channel_behaviour_crossfade_if_full = 2
216 };
217
218 enum probability_curve{
219 k_probability_curve_constant = 0,
220 k_probability_curve_wildlife_day = 1,
221 k_probability_curve_wildlife_night = 2
222 };
223
224 struct ent_font{
225 u32 alias,
226 variant_start,
227 variant_count,
228 glyph_start,
229 glyph_count,
230 glyph_utf32_base;
231 };
232
233 struct ent_font_variant{
234 u32 name,
235 material_id;
236 };
237
238 struct ent_glyph{
239 v2f size;
240 u32 indice_start,
241 indice_count;
242 };
243
244 #endif /* ENTITY_H */