| 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 |
#pragma once |
| 21 |
|
| 22 |
#include "d_array.h" |
| 23 |
#include "dsx-ns.h" |
| 24 |
#include "fwd-object.h" |
| 25 |
#include "fwd-segment.h" |
| 26 |
#include "fwd-weapon.h" |
| 27 |
#include "polyobj.h" |
| 28 |
#include "vecmat.h" |
| 29 |
#include <cstddef> |
| 30 |
#include <physfs.h> |
| 31 |
#include <type_traits> |
| 32 |
|
| 33 |
namespace dcx { |
| 34 |
|
| 35 |
enum class robot_gun_number : uint8_t; |
| 36 |
enum class robot_id : uint8_t; |
| 37 |
|
| 38 |
constexpr std::integral_constant<std::size_t, 8> MAX_GUNS{}; //should be multiple of 4 for ubyte array |
| 39 |
|
| 40 |
enum class robot_animation_state : uint8_t; |
| 41 |
#define N_ANIM_STATES 5 |
| 42 |
|
| 43 |
#define RI_CLOAKED_ALWAYS 1 |
| 44 |
|
| 45 |
struct jointpos; |
| 46 |
struct jointlist; |
| 47 |
|
| 48 |
constexpr std::integral_constant<unsigned, 16> ROBOT_NAME_LENGTH{}; |
| 49 |
|
| 50 |
struct d_level_shared_robot_joint_state; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
#ifdef DXX_BUILD_DESCENT |
| 55 |
namespace dsx { |
| 56 |
|
| 57 |
// Robot information |
| 58 |
struct robot_info; |
| 59 |
|
| 60 |
#if DXX_BUILD_DESCENT == 1 |
| 61 |
// maximum number of robot types |
| 62 |
constexpr std::integral_constant<unsigned, 30> MAX_ROBOT_TYPES{}; |
| 63 |
constexpr std::integral_constant<unsigned, 600> MAX_ROBOT_JOINTS{}; |
| 64 |
#elif DXX_BUILD_DESCENT == 2 |
| 65 |
// maximum number of robot types |
| 66 |
constexpr std::integral_constant<unsigned, 85> MAX_ROBOT_TYPES{}; |
| 67 |
constexpr std::integral_constant<unsigned, 1600> MAX_ROBOT_JOINTS{}; |
| 68 |
#endif |
| 69 |
|
| 70 |
using d_robot_info_array = enumerated_array<robot_info, MAX_ROBOT_TYPES, robot_id>; |
| 71 |
|
| 72 |
//the array of robots types |
| 73 |
struct d_level_shared_robot_info_state; |
| 74 |
extern d_level_shared_robot_info_state LevelSharedRobotInfoState; |
| 75 |
|
| 76 |
#if DXX_USE_EDITOR |
| 77 |
using robot_names_array = enumerated_array<std::array<char, ROBOT_NAME_LENGTH>, MAX_ROBOT_TYPES, robot_id>; |
| 78 |
extern robot_names_array Robot_names; |
| 79 |
#endif |
| 80 |
|
| 81 |
/* Robot joints can be customized by hxm files, which are per-level. |
| 82 |
*/ |
| 83 |
struct d_level_shared_robot_joint_state; |
| 84 |
extern d_level_shared_robot_joint_state LevelSharedRobotJointState; |
| 85 |
|
| 86 |
//given an object and a gun number, return position in 3-space of gun |
| 87 |
//fills in gun_point |
| 88 |
void calc_gun_point(const robot_info &, vms_vector &gun_point, const object_base &obj, robot_gun_number gun_num); |
| 89 |
|
| 90 |
/* |
| 91 |
* reads n robot_info structs from a PHYSFS_File |
| 92 |
*/ |
| 93 |
void robot_info_read(NamedPHYSFS_File fp, robot_info &r); |
| 94 |
void robot_set_angles(robot_info &r, const polymodel &pm, const enumerated_array<std::array<vms_angvec, MAX_SUBMODELS>, N_ANIM_STATES, robot_animation_state> &angs); |
| 95 |
weapon_id_type get_robot_weapon(const robot_info &ri, const robot_gun_number gun_num); |
| 96 |
|
| 97 |
} |
| 98 |
#endif |
| 99 |
|
| 100 |
/* |
| 101 |
* reads n jointpos structs from a PHYSFS_File |
| 102 |
*/ |
| 103 |
void jointpos_read(NamedPHYSFS_File fp, jointpos &jp); |