Debian Codegraph @

Descent3/matcen.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef _MATCEN_H_
20 #define _MATCEN_H_
21
22 #include "cfile.h"
23 #include "vecmat.h"
24 #include "matcen_external.h"
25
26 #define MAX_MATCENS 60
27 #define MAX_MATCEN_NAME_LEN 32
28
29 #define MATCEN_LOADSAVE_VERSION 3
30
31 #define MAX_MATCEN_ALIVE_CHILDREN 32
32
33 extern int Num_matcens;
34 extern bool Matcen_created;
35
36 #define MATCEN_OUTSIDE_NEAR_DIST 150.0f
37
38 #define MATCEN_ACTIVE_CHECK_RATE 4.0f
39 #define MATCEN_ACTIVE_CHECK_VARIENCE 1.0f
40
41 #define CHECK_ACTIVE_RATE 3.0f
42 #define CHECK_ACTIVE_VARIENCE 1.0f
43
44 #define MAX_MATCEN_EFFECT_SATURATION 2
45
46 #ifdef EDITOR
47 extern char *MatcenEffectStrings[NUM_MATCEN_EFFECTS];
48 #endif
49
50 // Versions
51 // 1 - Initial
52 // 2 - Added matcen effects
53 // 3 - Added matcen active_sound_handle
54
55 class matcen {
56 private:
57 // Static data -- only changes by OSIRIS
58 char m_name[MAX_MATCEN_NAME_LEN];
59
60 char m_num_prod_types;
61 char m_control_type;
62 char m_type;
63 char m_creation_effect;
64 int16_t m_creation_texture;
65 uint8_t m_cur_saturation_count;
66
67 int m_num_spawn_pnts;
68
69 union {
70 int m_roomnum;
71 int m_objref;
72 };
73
74 vector m_create_pnt;
75 int m_create_room;
76
77 int m_spawn_pnt[MAX_SPAWN_PNTS];
78 vector m_spawn_vec[MAX_SPAWN_PNTS];
79 vector m_spawn_normal[MAX_SPAWN_PNTS];
80 int16_t m_spawn_vis_effects[MAX_MATCEN_EFFECT_SATURATION][MAX_SPAWN_PNTS];
81
82 int m_max_prod;
83
84 int m_prod_type[MAX_PROD_TYPES];
85 float m_prod_time[MAX_PROD_TYPES];
86 int m_prod_priority[MAX_PROD_TYPES];
87 int m_max_prod_type[MAX_PROD_TYPES];
88
89 int16_t m_max_alive_children;
90 int16_t m_num_alive;
91 int *m_alive_list; // list of alive children
92
93 float m_preprod_time;
94 float m_postprod_time;
95
96 int m_sounds[MAX_MATCEN_SOUNDS];
97
98 float m_speed_multi;
99
100 // Dynamic values that change without scripting
101 char m_prod_mode;
102 float m_prod_mode_time;
103
104 int m_status;
105
106 int m_num_prod;
107 int m_last_prod_type_index;
108 float m_last_prod_finish_time;
109
110 int m_cached_prod_index;
111 float m_cached_prod_time;
112
113 int m_sound_active_handle;
114
115 float m_next_active_check_time;
116 bool m_last_active_check_result;
117
118 int m_last_prod_objref;
119
120 int m_num_prod_type[MAX_PROD_TYPES];
121
122 // Private functions that are not available outside of the matcen internals
123 bool StartObjProd();
124 bool DoObjProd();
125 bool FinishObjProd();
126
127 bool ComputeNextProdInfo();
128 bool ComputeCreatePnt();
129
130 void CheckActivateStatus();
131 bool DoAliveListFrame();
132 bool AddToAliveList(int objref);
133
134 public:
135 matcen();
136 ~matcen();
137
138 void SetCreationTexture(int16_t texnum);
139 int16_t GetCreationTexture();
140
141 char GetAttachType();
142 bool SetAttachType(char type);
143
144 char GetControlType();
145 bool SetControlType(char type);
146
147 int GetAttach();
148 bool SetAttach(int attach);
149
150 bool GetCreatePnt(vector *pnt);
151 bool SetCreatePnt(vector *pnt);
152 int GetCreateRoom();
153 bool SetCreateRoom(int room);
154
155 char GetNumSpawnPnts();
156 bool SetNumSpawnPnts(char num_s);
157
158 int GetSpawnPnt(char s_index);
159 bool SetSpawnPnt(char s_index, int s_value);
160
161 void SaveData(CFILE *fptr);
162 void LoadData(CFILE *fptr);
163
164 void GetName(char *);
165 bool SetName(const char *);
166
167 int GetMaxProd();
168 bool SetMaxProd(int max_p);
169
170 char GetNumProdTypes();
171 bool SetNumProdTypes(char num_prod_types);
172
173 bool GetProdInfo(char index, int *type_id, int *priority, float *time, int *max_prod);
174 bool SetProdInfo(char index, int *type_id, int *priority, float *time, int *max_prod);
175
176 float GetProdMultiplier();
177 bool SetProdMultiplier(float multi);
178
179 int GetStatus();
180 bool SetStatus(int status, bool f_enable); // Not all flags are settable
181
182 void DoThinkFrame();
183 void DoRenderFrame();
184
185 char GetCreationEffect();
186 bool SetCreationEffect(char effect_index);
187
188 int GetMaxAliveChildren();
189 bool SetMaxAliveChildren(int max_alive);
190
191 float GetPreProdTime();
192 bool SetPreProdTime(float time);
193
194 float GetPostProdTime();
195 bool SetPostProdTime(float time);
196
197 int GetSound(char sound_type);
198 bool SetSound(char sound_type, int sound_index);
199
200 void Reset();
201 };
202
203 extern matcen *Matcen[MAX_MATCENS];
204 int FindMatcenIndex(const char *name);
205 int CreateMatcen(const char *name, bool *f_name_changed);
206 void InitMatcens();
207
208 void DestroyAllMatcens();
209
210 void DestroyMatcen(int id, bool f_resort);
211
212 bool MatcenValid(int id);
213
214 void DoMatcensFrame();
215 void DoMatcensRenderFrame();
216 void InitMatcensForLevel();
217
218 #endif