my fucking fingers
[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_marker ent_marker;
20 typedef struct ent_traffic ent_traffic;
21 typedef struct ent_font ent_font;
22 typedef struct ent_font_variant ent_font_variant;
23 typedef struct ent_glyph ent_glyph;
24 typedef struct ent_skateshop ent_skateshop;
25 typedef struct ent_camera ent_camera;
26 typedef struct ent_swspreview ent_swspreview;
27
28 enum entity_alias{
29 k_ent_none = 0,
30 k_ent_gate = 1,
31 k_ent_spawn = 2,
32 k_ent_route_node = 3,
33 k_ent_route = 4,
34 k_ent_water = 5,
35 k_ent_volume = 6,
36 k_ent_audio = 7,
37 k_ent_marker = 8,
38 k_ent_font = 9,
39 k_ent_font_variant= 10,
40 k_ent_traffic = 11,
41 k_ent_skateshop = 12,
42 k_ent_camera = 13,
43 k_ent_swspreview = 14
44 };
45
46 static u32 mdl_entity_id_type( u32 entity_id )
47 {
48 return (entity_id & 0xffff0000) >> 16;
49 }
50
51 static u32 mdl_entity_id_id( u32 entity_id )
52 {
53 return entity_id & 0x0000ffff;
54 }
55
56 static u32 mdl_entity_id( u32 type, u32 index )
57 {
58 return (type & 0xfffff)<<16 | (index & 0xfffff);
59 }
60
61 enum entity_function{
62 k_ent_function_trigger,
63 k_ent_function_particle_spawn
64 };
65
66 struct ent_spawn{
67 mdl_transform transform;
68 u32 pstr_name;
69 };
70
71 enum light_type{
72 k_light_type_point = 0,
73 k_light_type_spot = 1
74 };
75
76 struct ent_light{
77 mdl_transform transform;
78 u32 daytime,
79 type;
80
81 v4f colour;
82 float angle,
83 range;
84
85 m4x3f inverse_world;
86 v2f angle_sin_cos;
87 };
88
89 enum gate_type{
90 k_gate_type_unlinked = 0,
91 k_gate_type_teleport = 1,
92 k_gate_type_nonlocal_unlinked = 2,
93 k_gate_type_nonlocel = 3
94 };
95
96 struct ent_gate{
97 u32 type,
98 target;
99
100 v3f dimensions,
101 co[2];
102
103 v4f q[2];
104
105 /* runtime */
106 m4x3f to_world, transport;
107
108 union{
109 u32 timing_version;
110
111 struct{
112 u8 ref_count;
113 };
114 };
115
116 double timing_time;
117 u16 routes[4]; /* routes that pass through this gate */
118 u8 route_count;
119 };
120
121 struct ent_route_node{
122 v3f co;
123 u8 ref_count, ref_total;
124 };
125
126 struct ent_path_index{
127 u16 index;
128 };
129
130 struct ent_checkpoint{
131 u16 gate_index,
132 path_start,
133 path_count;
134 };
135
136 struct ent_route{
137
138 union{
139 mdl_transform transform;
140 u32 official_track_id;
141 };
142
143 u32 pstr_name;
144 u16 checkpoints_start,
145 checkpoints_count;
146
147 v4f colour;
148
149 /* runtime */
150 u16 active_checkpoint,
151 valid_checkpoints;
152
153 float factive;
154 m4x3f board_transform;
155 mdl_submesh sm;
156 double timing_base;
157 };
158
159 struct ent_water{
160 mdl_transform transform;
161 float max_dist;
162 u32 reserved0, reserved1;
163 };
164
165 struct ent_audio_clip{
166 union{
167 mdl_file file;
168 audio_clip clip;
169 };
170
171 float probability;
172 };
173
174 struct volume_particles{
175 u32 blank, blank2;
176 };
177
178 struct volume_trigger{
179 u32 event, blank;
180 };
181
182 enum volume_subtype{
183 k_volume_subtype_trigger,
184 k_volume_subtype_particle
185 };
186
187 struct ent_volume{
188 mdl_transform transform;
189 m4x3f to_world, to_local;
190 u32 type;
191
192 u32 target;
193
194 union{
195 volume_trigger trigger;
196 volume_particles particles;
197 };
198 };
199
200 struct ent_audio{
201 mdl_transform transform;
202 u32 flags,
203 clip_start,
204 clip_count;
205 float volume, crossfade;
206 u32 behaviour,
207 group,
208 probability_curve,
209 max_channels;
210 };
211
212 struct ent_marker{
213 mdl_transform transform;
214 u32 pstr_alias;
215 };
216
217 struct ent_skateshop{
218 mdl_transform transform;
219 u32 id_display,
220 id_info,
221 id_rack,
222 id_camera;
223 };
224
225 struct ent_swspreview{
226 u32 id_camera, id_display, id_display1;
227 };
228
229 struct ent_traffic{
230 mdl_transform transform;
231 u32 submesh_start,
232 submesh_count,
233 start_node,
234 node_count;
235 float speed,
236 t;
237 u32 index; /* into the path */
238 };
239
240 struct ent_camera{
241 mdl_transform transform;
242 float fov;
243 };
244
245 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
246 mdl_array_ptr *arr, const char *alias )
247 {
248 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
249 ent_marker *marker = mdl_arritm( arr, i );
250
251 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
252 return marker;
253 }
254 }
255
256 return NULL;
257 }
258
259 enum channel_behaviour{
260 k_channel_behaviour_unlimited = 0,
261 k_channel_behaviour_discard_if_full = 1,
262 k_channel_behaviour_crossfade_if_full = 2
263 };
264
265 enum probability_curve{
266 k_probability_curve_constant = 0,
267 k_probability_curve_wildlife_day = 1,
268 k_probability_curve_wildlife_night = 2
269 };
270
271 struct ent_font{
272 u32 alias,
273 variant_start,
274 variant_count,
275 glyph_start,
276 glyph_count,
277 glyph_utf32_base;
278 };
279
280 struct ent_font_variant{
281 u32 name,
282 material_id;
283 };
284
285 struct ent_glyph{
286 v2f size;
287 u32 indice_start,
288 indice_count;
289 };
290
291
292 typedef struct ent_call ent_call;
293 struct ent_call{
294 u32 id, function;
295 void *data;
296 };
297
298 #include "world.h"
299
300 VG_STATIC void entity_call( world_instance *world, ent_call *call );
301
302 #endif /* ENTITY_H */