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