nonlocal stuff again
[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_unlinked = 2,
73 k_gate_type_nonlocel = 3
74 };
75
76 struct ent_gate{
77 u32 type,
78 target;
79
80 v3f dimensions,
81 co[2];
82
83 v4f q[2];
84
85 /* runtime */
86 m4x3f to_world, transport;
87
88 union{
89 u32 timing_version;
90
91 struct{
92 u8 ref_count;
93 };
94 };
95
96 double timing_time;
97 u16 routes[4]; /* routes that pass through this gate */
98 u8 route_count;
99 };
100
101 struct ent_route_node{
102 v3f co;
103 u8 ref_count, ref_total;
104 };
105
106 struct ent_path_index{
107 u16 index;
108 };
109
110 struct ent_checkpoint{
111 u16 gate_index,
112 path_start,
113 path_count;
114 };
115
116 struct ent_route{
117
118 union{
119 mdl_transform transform;
120 u32 official_track_id;
121 };
122
123 u32 pstr_name;
124 u16 checkpoints_start,
125 checkpoints_count;
126
127 v4f colour;
128
129 /* runtime */
130 u16 active_checkpoint,
131 valid_checkpoints;
132
133 float factive;
134 m4x3f board_transform;
135 mdl_submesh sm;
136 double timing_base;
137 };
138
139 struct ent_water{
140 mdl_transform transform;
141 float max_dist;
142 u32 reserved0, reserved1;
143 };
144
145 struct ent_audio_clip{
146 union{
147 mdl_file file;
148 audio_clip clip;
149 };
150
151 float probability;
152 };
153
154 struct volume_particles{
155 u32 blank, blank2;
156 };
157
158 struct volume_trigger{
159 u32 event, blank;
160 };
161
162 enum volume_subtype{
163 k_volume_subtype_trigger,
164 k_volume_subtype_particle
165 };
166
167 struct ent_volume{
168 mdl_transform transform;
169 m4x3f to_world, to_local;
170 u32 type;
171
172 ent_index target;
173
174 union{
175 volume_trigger trigger;
176 volume_particles particles;
177 };
178 };
179
180 struct ent_audio{
181 mdl_transform transform;
182 u32 flags,
183 clip_start,
184 clip_count;
185 float volume, crossfade;
186 u32 behaviour,
187 group,
188 probability_curve,
189 max_channels;
190 };
191
192 struct ent_marker{
193 mdl_transform transform;
194 u32 pstr_alias;
195 };
196
197 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
198 mdl_array_ptr *arr, const char *alias )
199 {
200 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
201 ent_marker *marker = mdl_arritm( arr, i );
202
203 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
204 return marker;
205 }
206 }
207
208 return NULL;
209 }
210
211 enum channel_behaviour{
212 k_channel_behaviour_unlimited = 0,
213 k_channel_behaviour_discard_if_full = 1,
214 k_channel_behaviour_crossfade_if_full = 2
215 };
216
217 enum probability_curve{
218 k_probability_curve_constant = 0,
219 k_probability_curve_wildlife_day = 1,
220 k_probability_curve_wildlife_night = 2
221 };
222
223 struct ent_font{
224 u32 alias,
225 variant_start,
226 variant_count,
227 glyph_start,
228 glyph_count,
229 glyph_utf32_base;
230 };
231
232 struct ent_font_variant{
233 u32 name,
234 material_id;
235 };
236
237 struct ent_glyph{
238 v2f size;
239 u32 indice_start,
240 indice_count;
241 };
242
243 #endif /* ENTITY_H */