Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | /* |
2 | * Portions of this file are copyright Rebirth contributors and licensed as |
||
3 | * described in COPYING.txt. |
||
4 | * Portions of this file are copyright Parallax Software and licensed |
||
5 | * according to the Parallax license below. |
||
6 | * See COPYING.txt for license details. |
||
7 | |||
8 | THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
||
9 | SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
||
10 | END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
||
11 | ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
||
12 | IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
||
13 | SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
||
14 | FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
||
15 | CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
||
16 | AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
||
17 | COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
||
18 | */ |
||
19 | |||
20 | /* |
||
21 | * |
||
22 | * Definitions for fueling centers. |
||
23 | * |
||
24 | */ |
||
25 | |||
26 | #pragma once |
||
27 | |||
28 | #ifdef __cplusplus |
||
29 | #include "pack.h" |
||
30 | #include "fwd-object.h" |
||
31 | #include "fwd-segment.h" |
||
32 | #include "fwd-vecmat.h" |
||
33 | |||
34 | //------------------------------------------------------------ |
||
35 | // A refueling center is one segment... to identify it in the |
||
36 | // segment structure, the "special" field is set to |
||
37 | // SEGMENT_IS_FUELCEN. The "value" field is then used for how |
||
38 | // much fuel the center has left, with a maximum value of 100. |
||
39 | |||
40 | //------------------------------------------------------------- |
||
41 | // To hook into Inferno: |
||
42 | // * When all segents are deleted or before a new mine is created |
||
43 | // or loaded, call fuelcen_reset(). |
||
44 | // * Add call to fuelcen_create(segment * segp) to make a segment |
||
45 | // which isn't a fuel center be a fuel center. |
||
46 | // * When a mine is loaded call fuelcen_activate(segp) with each |
||
47 | // new segment as it loads. Always do this. |
||
48 | // * When a segment is deleted, always call fuelcen_delete(segp). |
||
49 | // * When an object that needs to be refueled is in a segment, call |
||
50 | // fuelcen_give_fuel(segp) to get fuel. (Call once for any refueling |
||
51 | // object once per frame with the object's current segment.) This |
||
52 | // will return a value between 0 and 100 that tells how much fuel |
||
53 | // he got. |
||
54 | |||
55 | |||
56 | #ifdef dsx |
||
57 | namespace dsx { |
||
58 | // Destroys all fuel centers, clears segment backpointer array. |
||
59 | void fuelcen_reset(); |
||
60 | |||
61 | // Makes a segment a fuel center. |
||
62 | void fuelcen_create( vmsegptridx_t segp); |
||
63 | // Makes a fuel center active... needs to be called when |
||
64 | // a segment is loaded from disk. |
||
65 | void fuelcen_activate(vmsegptridx_t segp); |
||
66 | // Deletes a segment as a fuel center. |
||
67 | void fuelcen_delete(vmsegptr_t segp); |
||
68 | |||
69 | // Create a matcen robot |
||
70 | imobjptridx_t create_morph_robot(vmsegptridx_t segp, const vms_vector &object_pos, unsigned object_id); |
||
71 | |||
72 | // Returns the amount of fuel/shields this segment can give up. |
||
73 | // Can be from 0 to 100. |
||
74 | fix fuelcen_give_fuel(const shared_segment &segp, fix MaxAmountCanTake); |
||
75 | } |
||
76 | |||
77 | // Call once per frame. |
||
78 | void fuelcen_update_all(); |
||
79 | |||
80 | // Called to repair an object |
||
81 | //--repair-- int refuel_do_repair_effect( object * obj, int first_time, int repair_seg ); |
||
82 | |||
83 | namespace dsx { |
||
84 | #if defined(DXX_BUILD_DESCENT_II) |
||
85 | fix repaircen_give_shields(const shared_segment &segp, fix MaxAmountCanTake); |
||
86 | #endif |
||
87 | } |
||
88 | #endif |
||
89 | |||
90 | //--repair-- //do the repair center for this frame |
||
91 | //--repair-- void do_repair_sequence(object *obj); |
||
92 | //--repair-- |
||
93 | //--repair-- //see if we should start the repair center |
||
94 | //--repair-- void check_start_repair_center(object *obj); |
||
95 | //--repair-- |
||
96 | //--repair-- //if repairing, cut it short |
||
97 | //--repair-- abort_repair_center(); |
||
98 | |||
99 | namespace dcx { |
||
100 | |||
101 | // An array of pointers to segments with fuel centers. |
||
102 | struct FuelCenter : public prohibit_void_ptr<FuelCenter> |
||
103 | { |
||
104 | segnum_t segnum; |
||
105 | uint8_t Type; |
||
106 | sbyte Flag; |
||
107 | sbyte Enabled; |
||
108 | sbyte Lives; // Number of times this can be enabled. |
||
109 | fix Capacity; |
||
110 | fix Timer; // used in matcen for when next robot comes out |
||
111 | fix Disable_time; // Time until center disabled. |
||
112 | }; |
||
113 | |||
114 | // The max number of robot centers per mine. |
||
115 | struct d1_matcen_info : public prohibit_void_ptr<d1_matcen_info> |
||
116 | { |
||
117 | std::array<unsigned, 1> robot_flags; // Up to 32 different robots |
||
118 | segnum_t segnum; // Segment this is attached to. |
||
119 | short fuelcen_num; // Index in fuelcen array. |
||
120 | }; |
||
121 | |||
122 | struct d_level_unique_fuelcenter_state |
||
123 | { |
||
124 | unsigned Num_fuelcenters; |
||
125 | // Original D1 size: 50, Original D2 size: 70 |
||
126 | std::array<FuelCenter, 128> Station; |
||
127 | }; |
||
128 | |||
129 | extern d_level_unique_fuelcenter_state LevelUniqueFuelcenterState; |
||
130 | |||
131 | } |
||
132 | |||
133 | #ifdef dsx |
||
134 | namespace dsx { |
||
135 | #if defined(DXX_BUILD_DESCENT_I) |
||
136 | typedef d1_matcen_info matcen_info; |
||
137 | void matcen_info_read(PHYSFS_File *fp, matcen_info &ps, int version); |
||
138 | #elif defined(DXX_BUILD_DESCENT_II) |
||
139 | struct matcen_info : public prohibit_void_ptr<matcen_info> |
||
140 | { |
||
141 | std::array<unsigned, 2> robot_flags; // Up to 64 different robots |
||
142 | segnum_t segnum; // Segment this is attached to. |
||
143 | short fuelcen_num; // Index in fuelcen array. |
||
144 | }; |
||
145 | |||
146 | void matcen_info_read(PHYSFS_File *fp, matcen_info &ps); |
||
147 | #endif |
||
148 | |||
149 | extern const char Special_names[MAX_CENTER_TYPES][11]; |
||
150 | |||
151 | struct d_level_shared_robotcenter_state |
||
152 | { |
||
153 | unsigned Num_robot_centers; |
||
154 | // Original D1/D2 size: 20 |
||
155 | std::array<matcen_info, 128> RobotCenters; |
||
156 | }; |
||
157 | |||
158 | extern d_level_shared_robotcenter_state LevelSharedRobotcenterState; |
||
159 | |||
160 | // Called when a materialization center gets triggered by the player |
||
161 | // flying through some trigger! |
||
162 | void trigger_matcen(vmsegptridx_t segnum); |
||
163 | |||
164 | extern void disable_matcens(void); |
||
165 | |||
166 | extern void init_all_matcens(void); |
||
167 | |||
168 | /* |
||
169 | * reads a matcen_info structure from a PHYSFS_File |
||
170 | */ |
||
171 | #if defined(DXX_BUILD_DESCENT_II) |
||
172 | void fuelcen_check_for_hoard_goal(object &plrobj, const shared_segment &segp); |
||
173 | |||
174 | /* |
||
175 | * reads an d1_matcen_info structure from a PHYSFS_File |
||
176 | */ |
||
177 | void d1_matcen_info_read(PHYSFS_File *fp, matcen_info &mi); |
||
178 | #endif |
||
179 | |||
180 | void matcen_info_write(PHYSFS_File *fp, const matcen_info &mi, short version); |
||
181 | } |
||
182 | |||
183 | namespace dcx { |
||
184 | constexpr std::integral_constant<uint8_t, 0xff> station_none{}; |
||
185 | extern const fix EnergyToCreateOneRobot; |
||
186 | } |
||
187 | #endif |
||
188 | |||
189 | void fuelcen_read(PHYSFS_File *fp, FuelCenter &fc); |
||
190 | void fuelcen_write(PHYSFS_File *fp, const FuelCenter &fc); |
||
191 | |||
192 | #endif |