| 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-robot.h" |
| 32 |
#include "fwd-segment.h" |
| 33 |
#include "fwd-vecmat.h" |
| 34 |
#include "d_array.h" |
| 35 |
#include "physfsx.h" |
| 36 |
|
| 37 |
//------------------------------------------------------------ |
| 38 |
// A refueling center is one segment... to identify it in the |
| 39 |
// segment structure, the "special" field is set to |
| 40 |
// segment_special::fuelcen. The "value" field is then used for how |
| 41 |
// much fuel the center has left, with a maximum value of 100. |
| 42 |
|
| 43 |
//------------------------------------------------------------- |
| 44 |
// To hook into Inferno: |
| 45 |
// * When all segents are deleted or before a new mine is created |
| 46 |
// or loaded, call fuelcen_reset(). |
| 47 |
// * Add call to fuelcen_create(segment * segp) to make a segment |
| 48 |
// which isn't a fuel center be a fuel center. |
| 49 |
// * When a mine is loaded call fuelcen_activate(segp) with each |
| 50 |
// new segment as it loads. Always do this. |
| 51 |
// * When a segment is deleted, always call fuelcen_delete(segp). |
| 52 |
// * When an object that needs to be refueled is in a segment, call |
| 53 |
// fuelcen_give_fuel(segp) to get fuel. (Call once for any refueling |
| 54 |
// object once per frame with the object's current segment.) This |
| 55 |
// will return a value between 0 and 100 that tells how much fuel |
| 56 |
// he got. |
| 57 |
|
| 58 |
|
| 59 |
#ifdef DXX_BUILD_DESCENT |
| 60 |
namespace dsx { |
| 61 |
// Destroys all fuel centers, clears segment backpointer array. |
| 62 |
void fuelcen_reset(); |
| 63 |
|
| 64 |
// Makes a segment a fuel center. |
| 65 |
void fuelcen_create( vmsegptridx_t segp); |
| 66 |
// Makes a fuel center active... needs to be called when |
| 67 |
// a segment is loaded from disk. |
| 68 |
void fuelcen_activate(vmsegptridx_t segp); |
| 69 |
// Deletes a segment as a fuel center. |
| 70 |
void fuelcen_delete(shared_segment &segp); |
| 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(const d_robot_info_array &Robot_info); |
| 79 |
#endif |
| 80 |
|
| 81 |
//--repair-- //do the repair center for this frame |
| 82 |
//--repair-- void do_repair_sequence(object *obj); |
| 83 |
//--repair-- |
| 84 |
//--repair-- //see if we should start the repair center |
| 85 |
//--repair-- void check_start_repair_center(object *obj); |
| 86 |
//--repair-- |
| 87 |
//--repair-- //if repairing, cut it short |
| 88 |
//--repair-- abort_repair_center(); |
| 89 |
|
| 90 |
namespace dcx { |
| 91 |
|
| 92 |
// An array of pointers to segments with fuel centers. |
| 93 |
struct FuelCenter : public prohibit_void_ptr<FuelCenter> |
| 94 |
{ |
| 95 |
segnum_t segnum; |
| 96 |
segment_special Type; |
| 97 |
sbyte Flag; |
| 98 |
sbyte Enabled; |
| 99 |
sbyte Lives; // Number of times this can be enabled. |
| 100 |
fix Capacity; |
| 101 |
fix Timer; // used in matcen for when next robot comes out |
| 102 |
fix Disable_time; // Time until center disabled. |
| 103 |
}; |
| 104 |
|
| 105 |
// The max number of robot centers per mine. |
| 106 |
struct d1_matcen_info : public prohibit_void_ptr<d1_matcen_info> |
| 107 |
{ |
| 108 |
std::array<unsigned, 1> robot_flags; // Up to 32 different robots |
| 109 |
segnum_t segnum; // Segment this is attached to. |
| 110 |
station_number fuelcen_num; // Index in fuelcen array. |
| 111 |
}; |
| 112 |
|
| 113 |
struct d_level_unique_fuelcenter_state |
| 114 |
{ |
| 115 |
unsigned Num_fuelcenters; |
| 116 |
// Original D1 size: 50, Original D2 size: 70 |
| 117 |
enumerated_array<FuelCenter, 128, station_number> Station; |
| 118 |
}; |
| 119 |
|
| 120 |
extern d_level_unique_fuelcenter_state LevelUniqueFuelcenterState; |
| 121 |
|
| 122 |
#ifdef DXX_BUILD_DESCENT |
| 123 |
fix repaircen_give_shields(const shared_segment &segp, fix MaxAmountCanTake); |
| 124 |
#endif |
| 125 |
} |
| 126 |
|
| 127 |
#ifdef DXX_BUILD_DESCENT |
| 128 |
namespace dsx { |
| 129 |
#if DXX_BUILD_DESCENT == 1 |
| 130 |
typedef d1_matcen_info matcen_info; |
| 131 |
void matcen_info_read(NamedPHYSFS_File fp, matcen_info &ps, int version); |
| 132 |
#elif DXX_BUILD_DESCENT == 2 |
| 133 |
struct matcen_info : public prohibit_void_ptr<matcen_info> |
| 134 |
{ |
| 135 |
std::array<unsigned, 2> robot_flags; // Up to 64 different robots |
| 136 |
segnum_t segnum; // Segment this is attached to. |
| 137 |
station_number fuelcen_num; // Index in fuelcen array. |
| 138 |
}; |
| 139 |
|
| 140 |
void matcen_info_read(NamedPHYSFS_File fp, matcen_info &ps); |
| 141 |
#endif |
| 142 |
|
| 143 |
#if DXX_USE_EDITOR |
| 144 |
extern const enumerated_array<char[11], MAX_CENTER_TYPES, segment_special> Special_names; |
| 145 |
#endif |
| 146 |
|
| 147 |
struct d_level_shared_robotcenter_state |
| 148 |
{ |
| 149 |
unsigned Num_robot_centers; |
| 150 |
// Original D1/D2 size: 20 |
| 151 |
enumerated_array<matcen_info, 128, materialization_center_number> RobotCenters; |
| 152 |
}; |
| 153 |
|
| 154 |
extern d_level_shared_robotcenter_state LevelSharedRobotcenterState; |
| 155 |
|
| 156 |
// Called when a materialization center gets triggered by the player |
| 157 |
// flying through some trigger! |
| 158 |
void trigger_matcen(vmsegptridx_t segnum); |
| 159 |
|
| 160 |
extern void disable_matcens(void); |
| 161 |
|
| 162 |
extern void init_all_matcens(void); |
| 163 |
|
| 164 |
/* |
| 165 |
* reads a matcen_info structure from a PHYSFS_File |
| 166 |
*/ |
| 167 |
#if DXX_BUILD_DESCENT == 2 |
| 168 |
void fuelcen_check_for_hoard_goal(object &plrobj, const shared_segment &segp); |
| 169 |
|
| 170 |
/* |
| 171 |
* reads an d1_matcen_info structure from a PHYSFS_File |
| 172 |
*/ |
| 173 |
void d1_matcen_info_read(NamedPHYSFS_File fp, matcen_info &mi); |
| 174 |
#endif |
| 175 |
|
| 176 |
void matcen_info_write(PHYSFS_File *fp, const matcen_info &mi, short version); |
| 177 |
} |
| 178 |
|
| 179 |
namespace dcx { |
| 180 |
extern const fix EnergyToCreateOneRobot; |
| 181 |
} |
| 182 |
#endif |
| 183 |
|
| 184 |
void fuelcen_read(NamedPHYSFS_File fp, FuelCenter &fc); |
| 185 |
void fuelcen_write(PHYSFS_File *fp, const FuelCenter &fc); |
| 186 |
|
| 187 |
#endif |